B
billk
How can i use transaction when accessing simple text files with ADO.NET?
For example i have the following code: (of course is not working
----------------------------------------------------------------------------
------------
Dim conn As OdbcConnection = New OdbcConnection("DSN=testtext")
conn.Open()
Dim myCommand As OdbcCommand = conn.CreateCommand()
Dim myTrans As OdbcTransaction
' Start a local transaction
myTrans = conn.BeginTransaction '<----ERROR: transaction not supported in
text files
' Assign transaction object for a pending local transaction
'myCommand.Transaction = myTrans
Try
myCommand.CommandText = "Update Orders.txt Set ShipCity='Athens' where
customerid ='ALFKI'" '<----ERROR: UPDATE not supported in text files
myCommand.ExecuteNonQuery()
myTrans.Commit()
Catch ex1 As Exception
Try
myTrans.Rollback()
Catch ex As OdbcException
If Not myTrans.Connection Is Nothing Then
End If
End Try
Finally
conn.Close()
End Try
----------------------------------------------------------------------------
--------------------------------------
From what i know INSERT/UPDATE/DELETE are not supported with the text ODBC
driver, so how can i use INSERT/UPDATE/DELETE or Transaction with ADO.NET
when working with text files ??
Any samples or URL'S are welcome.
Thanks
Bill
For example i have the following code: (of course is not working
----------------------------------------------------------------------------
------------
Dim conn As OdbcConnection = New OdbcConnection("DSN=testtext")
conn.Open()
Dim myCommand As OdbcCommand = conn.CreateCommand()
Dim myTrans As OdbcTransaction
' Start a local transaction
myTrans = conn.BeginTransaction '<----ERROR: transaction not supported in
text files
' Assign transaction object for a pending local transaction
'myCommand.Transaction = myTrans
Try
myCommand.CommandText = "Update Orders.txt Set ShipCity='Athens' where
customerid ='ALFKI'" '<----ERROR: UPDATE not supported in text files
myCommand.ExecuteNonQuery()
myTrans.Commit()
Catch ex1 As Exception
Try
myTrans.Rollback()
Catch ex As OdbcException
If Not myTrans.Connection Is Nothing Then
End If
End Try
Finally
conn.Close()
End Try
----------------------------------------------------------------------------
--------------------------------------
From what i know INSERT/UPDATE/DELETE are not supported with the text ODBC
driver, so how can i use INSERT/UPDATE/DELETE or Transaction with ADO.NET
when working with text files ??
Any samples or URL'S are welcome.
Thanks
Bill