Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Transactions with a DBF
Message
De
24/04/2004 09:58:20
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
23/04/2004 18:27:29
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro et .NET
Divers
Thread ID:
00897819
Message ID:
00897892
Vues:
13
This message has been marked as a message which has helped to the initial question of the thread.
>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform