Results 1 to 3 of 3

Thread: vb.net modify mdb database NEED HELP!

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    1

    vb.net modify mdb database NEED HELP!

    can anyone show me how to update a access database using vb .net?

    the coding i have is this:

    Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=""c:\databasename.mdb"";"

    Dim objConn As New OleDb.OleDbConnection(connectionString)
    objConn.Open()

    Dim ds As New DataSet
    Dim da2 As OleDb.OleDbDataAdapter
    Dim sql As String

    sql = "SELECT [Name] FROM Developer"


    da2 = New OleDb.OleDbDataAdapter(sql, objConn)

    da2.Fill(ds, "Developer")

    Dim cb As New OleDb.OleDbCommandBuilder(da2)



    ds.Tables("Developer").Rows(0).Item(0) = "yes"


    da2.Update(ds, "Developer")

    but it give me an "Invalid Operation Exception" ---"Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information."

    can anyone tell me why?

  2. #2
    Frenzied Member maged's Avatar
    Join Date
    Nov 2002
    Location
    Egypt
    Posts
    1,040

    Re: vb.net modify mdb database NEED HELP!

    before updating you must set the update commands the dataadapter will use to update the database. if you don't wish to write this update commands manually, just let the framework creats them on runtime for you.

    how by using a sqlcommandbuilder like this :

    VB Code:
    1. 'insert these lines before the last line which contains the update method
    2. dim buildx as new sqlcommandbuilder(da2) ' this makes the command builder creates the update commands for you automatically.
    3.  
    4. 'update as you have been doind
    5. da2.update("whatever")


    this will solve your problem

    rgds

  3. #3
    Frenzied Member maged's Avatar
    Join Date
    Nov 2002
    Location
    Egypt
    Posts
    1,040

    Re: vb.net modify mdb database NEED HELP!

    and welcome to the forums

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width