>I'm updating a .dbf table in VB.NET using the Microsoft.Jet.OLEDB.4.0 provider. I'm not sure if it's a FoxPro .DBF, or another "flavor" of .DBF, but the code I "inherited" (don't you love those?) uses "Extended Properties='DBASE IV'" in the connection string.
>
>My question is, are transactions supported in this situation? My preliminary testing seems to indicate not, but I want to check with the experts before I come to any rash conclusions. :) Here's my test code. After running, ei_sent is still 1. The Rollback didn't roll back. This same code with the sqloledb provider works perfectly. After running, ei_sent is still 0. Am I doing something wrong, or are transactions just not suppoerted with Jet? Or is there another way I should handle transactions with Jet and/or a .DBF database?
>
>Imports System.Data
>Imports System.Data.OleDb
>
>Module Module1
> Public Sub Main()
> Dim ConnectionString As String = _
> "Provider=Microsoft.Jet.OLEDB.4.0;" & _
> "Data Source=C:\softphrm\data;" & _
> "Extended Properties='DBASE IV';"
> Dim sql As String = _
> "UPDATE qn_ei " & _
> " SET ei_sent=1 " & _
> " WHERE ei_sent=0"
>
> Dim cnn As New OleDbConnection(ConnectionString)
> Dim trn As OleDbTransaction
> cnn.Open()
> trn = cnn.BeginTransaction()
>
> Dim cmd As New OleDbCommand(sql, cnn)
> cmd.Transaction = trn
>
> cmd.ExecuteNonQuery()
> trn.Rollback()
> cnn.Close()
> End Sub
>End Module
>
>-----
>Lee Perkins
Lee,
You might use VFPOLEDB which supports transaction. ie:
using System;
using System.Data;
using System.Data.OleDb;
namespace VFPTransaction
{
class myClass
{
[STAThread]
static void Main(string[] args)
{
string strConn = "Provider=VFPOLEDB;Data source=C:\\softphrm\\data;";
string strUpdate = "UPDATE qn_ei " +
" SET ei_sent=1 " +
" WHERE ei_sent=0";
OleDbConnection cn = new OleDbConnection(strConn);
cn.Open();
OleDbCommand cmd = cn.CreateCommand();
cmd.CommandText = strUpdate;
OleDbTransaction trn = cn.BeginTransaction();
cmd.Transaction=trn;
cmd.ExecuteNonQuery();
trn.Rollback();
cn.Close();
}
}
}
Cetin