Update a dBase dbf-7 table using OleDB .NET

Discussion in '.NET' started by Aurelio, Jan 2, 2006.

  1. Aurelio

    Aurelio

    Joined:
    Jan 2, 2006
    Messages:
    1
    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
    -------------------------------------------------------------------------
    Aurelio, Jan 2, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JeffP@Laptop

    dBase VFP OleDb or ODBC Drivers

    JeffP@Laptop, Jan 25, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    2,772
    JeffP@Laptop
    Jan 25, 2006
  2. yefei
    Replies:
    0
    Views:
    563
    yefei
    Mar 31, 2006
  3. Glenn Robinson

    Can't seem to UPDATE dBase table

    Glenn Robinson, Jun 18, 2004, in forum: Java
    Replies:
    5
    Views:
    1,797
    Glenn Robinson
    Jun 19, 2004
  4. Helmut Jarausch
    Replies:
    4
    Views:
    6,453
    Ethan Furman
    Jul 15, 2009
  5. Ethan Furman

    ANN: dbf (aka Python dBase)

    Ethan Furman, Mar 1, 2013, in forum: Python
    Replies:
    0
    Views:
    160
    Ethan Furman
    Mar 1, 2013
Loading...

Share This Page