Question Weird behavior with SQL UPDATE statement on DBF

luigi.freguglia

New member
Joined
Feb 1, 2011
Messages
1
Programming Experience
10+
Hello, i'm really stuck on a apparently simple statement.

I'm working on a DBF table. When I open the file in a program called "DBF Viewer 2000", it states that the file is a "FoxBase+/dBASE III PLUSE, no memo".

If i run this VB.NET code

VB.NET:
  Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & opt.path & "\" & ";Extended Properties=dBase III;"
        Dim oledbAdapterIns As New OleDbDataAdapter()
        Dim InsConnection As New OleDbConnection(ConnectionString)
        oledbAdapterIns = New OleDbDataAdapter()
        InsConnection = New OleDbConnection(ConnectionString)
        Try
            InsConnection.Open()
            Dim s As String
            s = "UPDATE LIBRIAZ SET LIBRIAZ.ULTNUM=6 WHERE LIBRIAZ.REGISTRO='CW' AND LIBRIAZ.ANNO='2011' AND LIBRIAZ.CHIAVE='ORD_REG'"
            oledbAdapterIns.InsertCommand = New OleDbCommand(s, InsConnection)
            Dim rows As Integer = oledbAdapterIns.InsertCommand.ExecuteNonQuery()
        Catch ex As Exception
            Debug.Writeline(ex.Message)
        End Try
        oledbAdapterIns.Dispose()
        InsConnection.Dispose()

it runs without error BUT not updating the table.

There is exactly one record responding to these three conditions.

Now comes the weird: if I remove one condition
VB.NET:
LIBRIAZ.REGISTRO='CW' AND LIBRIAZ.ANNO='2011' AND LIBRIAZ.CHIAVE='ORD_REG'
for example
VB.NET:
LIBRIAZ.ANNO='2011' AND LIBRIAZ.CHIAVE='ORD_REG'
the UPDATE works, setting LIBRIAZ.ULTNUM to 6

It's not a matter of which condition i remove, because it's enough to remove one of them to get the UPDATE working.

It's days I'm trying to figure why this behavior... now i'm pretty desperate.

Anyone have a clue?:confused:
 
Back
Top