Update a dBase dbf-7 table using OleDB .NET


Joined
Jan 2, 2006
Messages
1
Reaction score
0
I am using the CommandBuilder to auto-build the update commands.
My select command is very simple like "Select * From MyTable", where
MyTable is a real dBase DBF-7 table. But I got a runtime error when it
comes to the Update command:

"Dynamic SQL generation for the UpdateCommand is not supported against a
SelectCommand that does not return any key column information"

I have assigned a column as PrimaryKey, but this also doesn't works.
Even when I create a 'Primary Key' using the dBase IDE.

Does somebody have updated a dBase dbf-7 table using OleDB .NET?
Any help will be appreciated.


Aurelio Jaraiz.


The code snippet is as follows:

-------------------------------------------------------------------------
Dim myDataSet As DataSet = New DataSet

Dim strConexion As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "C:\SampleDataSet" & ";Extended Properties=""DBASE 5.0"";"
Dim myConnection As OleDbConnection = New OleDbConnection(strConexion)

Dim myOleDbDataAdapter As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM TEST1", myConnection)
Dim myDataRowsCommandBuilder As OleDbCommandBuilder = New OleDbCommandBuilder(myOleDbDataAdapter)

myConnection.Open()

myOleDbDataAdapter.Fill(myDataSet, "Test1")
Dim myTable As DataTable = myDataSet.Tables("Test1")
Dim colKey(1) As DataColumn
colKey(0) = myTable.Columns(0)
myTable.PrimaryKey = colKey

myTable.Rows(0).Item("Nombre") = "New name"

Try
myOleDbDataAdapter.Update(myTable) '**** error****
Catch ex As Exception
Dim mensaje As String = ex.Message
End Try

myConnection.Close()
-------------------------------------------------------------------------

The DBF 7 Table Structure ("Test1"):

Field Name Type Len Dec Index
1 Autonum AUTOINC 4 N
2 Nombre CHAR 50 N
3 Numero NUMERIC 10 2 N
-------------------------------------------------------------------------
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top