Results 1 to 6 of 6

Thread: Help with Dataset update

  1. #1

    Thread Starter
    Lively Member Xcoder's Avatar
    Join Date
    Jan 2004
    Posts
    120

    Help with Dataset update

    I have a mdb file and I access it through ADO.NET, from time to time I have to update an existing record, so I do this:

    VB Code:
    1. Dim dsDataGen As New DataSet
    2. Dim daDataGen As OleDbDataAdapter
    3. Dim cbDataGen As OleDbCommandBuilder
    4.  
    5. Private Sub Data_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    6. daDataGen = New OleDbDataAdapter("SELECT * FROM [mytable]", strConnConfig)
    7. daDataGen.MissingSchemaAction = MissingSchemaAction.AddWithKey
    8. daDataGen.Fill(dsDataGen, "general")
    9. cbDataGen = New OleDbCommandBuilder(daDataGen)
    10. End Sub
    11.  
    12. Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
    13.  
    14. Try
    15.       If dsDataGen Is Nothing Then Return
    16.  
    17.                 With dsDataGen.Tables("general")
    18.                     .Rows(0)("name_e") = txt_nombre.Text
    19.                     .Rows(0)("add_e") = txt_address.Text
    20.                     .Rows(0)("phone_e") = txt_phone.Text
    21.                     .Rows(0)("email_e") = txt_email.Text
    22.  
    23.                     daDataGen.Update(dsDataGen, "general")
    24.                    
    25.                 End With
    26.  
    27. Catch ex As Exception
    28.      MessageBox.Show(ex.Message, "MyApp", MessageBoxButtons.OK)
    29. End Try

    But I get a "Syntax error in Update statement" the moment it steps out of daDataGen.Update(dsDataGen, "general") , I really dont know why. Please help
    Last edited by Xcoder; Sep 8th, 2006 at 08:17 AM.

  2. #2
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    Re: Help with Dataset update

    what does the error massage says?

  3. #3
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    Re: Help with Dataset update

    And what is the "general"? is it a table? I don't see that table on the top statments!

  4. #4
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    Re: Help with Dataset update

    But I get a "Syntax error in Update statement" the moment it steps out of daDataGen.Update(dsDataGen, "general") , I really dont know why. Please help
    Well! Help me to help you

  5. #5

    Thread Starter
    Lively Member Xcoder's Avatar
    Join Date
    Jan 2004
    Posts
    120

    Re: Help with Dataset update

    Yes, my mistake, I have fixed that here, I have it right in the code. Just a typo when I was editing this post sorry. Yes the error it says is "Syntax Error in Update Statement".

  6. #6

    Thread Starter
    Lively Member Xcoder's Avatar
    Join Date
    Jan 2004
    Posts
    120

    Re: Help with Dataset update

    I think the problem lays on the "general" table which is a real one, I think thats a restricted word in SQL, what can I do? manually edit the update command?

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