This is exactly the kind of test I did... I try your code...and when we are
"Cindy Winegarden" wrote:
> Hi Stéphane,
>
> I had time to play with this today:
>
>
> Imports System
> Imports System.Data
> Imports System.Data.OleDb
>
> Module Module1
>
> Sub Main()
>
> Dim conn As New OleDbConnection( _
> "Provider=VFPOLEDB.1;Data Source = C:\Temp;")
> conn.Open()
>
> '-- Let's create some data to work with
> Dim cmd1 As New OleDbCommand("Create Table TestTrans (Field1 C(10))",
> conn)
> Dim cmd2 As New OleDbCommand("Insert Into TestTrans Values ('Hello')",
> conn)
> cmd1.ExecuteNonQuery()
> cmd2.ExecuteNonQuery()
>
> '-- Now let's see what the data looks like
> Dim da As New OleDbDataAdapter("Select * From TestTrans", conn)
> Dim ds1 As New DataSet
> da.Fill(ds1)
> MsgBox("Say hello: " & ds1.Tables(0).Rows(0).Item(0).ToString())
> MsgBox("Count of rows: " & ds1.Tables(0).Rows().Count.ToString)
>
> '-- Make it transactable
> Dim cmd3 As New OleDbCommand("MakeTransactable('TestTrans')", conn)
> cmd3.ExecuteNonQuery()
>
> '-- Use a Transaction and Commit it
> Dim trans1 As OleDbTransaction = conn.BeginTransaction()
>
> Dim cmd4 As New OleDbCommand("Insert Into TestTrans Values ('World')",
> conn, trans1)
> cmd4.ExecuteNonQuery()
> trans1.Commit()
>
> Dim ds2 As New DataSet
> da.Fill(ds2)
> MsgBox("Say hello: " & ds2.Tables(0).Rows(0).Item(0).ToString())
> MsgBox("Count of rows: " & ds2.Tables(0).Rows().Count.ToString)
>
> Dim trans2 As OleDbTransaction = conn.BeginTransaction()
> Dim cmd5 As New OleDbCommand("Insert Into TestTrans Values ('Not!!!')",
> conn, trans2)
> cmd5.ExecuteNonQuery()
> trans2.Rollback()
>
> Dim ds3 As New DataSet
> da.Fill(ds3)
> MsgBox("Count of rows: " & ds3.Tables(0).Rows().Count.ToString)
>
> End Sub
>
> End Module
>
>
> --
> Cindy Winegarden MCSD, Microsoft Visual Foxpro MVP
> cindy_winegarden@msn.com
www.cindywinegarden.com > Blog:
http://spaces.msn.com/members/cindywinegarden >
>
> "Stéphane" <Stphane@discussions.microsoft.com> wrote in message
> news:DB3EFFF4-F7DF-45F5-A9C1-6988380311B6@microsoft.com...
> > Thanks Cindy,
> >
> > I convert the sample code to Visual Basic 6 and it work.
> >
> > But I was unable to make it work with ado.net :(
>
>