Update table from datagrid

Posted on 2006-04-04
Medium Priority
Last Modified: 2008-01-09

I have a datagrid which fills properly from my datasource.  However, I am unable to save any changes.  When I hit the save button I get:  "ERROR [23000] [MySQL][ODBC 3.51 Driver][mysqld-5.0.15-nt]You have an error in your SQL syntax "   I have spent hours on this so any help is appreciated.


Imports System.Data.odbc

Public Class frmAdminLists
    Private cb As OdbcCommandBuilder

    Private Sub frmAdminLists_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub

    Private Sub lblDelInst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblDelInst.Click
        cb = New OdbcCommandBuilder(daDelInst)
        daDelInst.Fill(dsDelInst, "Fontana_DelInst")
        dgDelInst.DataSource = dsDelInst.Tables("Fontana_DelInst")
    End Sub
    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click

        Dim ds_New As DataSet = dsDelInst.GetChanges()

        daDelInst.Update(ds_New, "Fontana_DelInst")   <<<<<<<ERROR IS HERE>>>>>>>

    End Sub

End Class
Question by:maralans
LVL 14

Accepted Solution

amyhxu earned 2000 total points
ID: 16378450
How about this:

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click

        daDelInst.Update(dsDelInst, "Fontana_DelInst")

    End Sub

Author Comment

ID: 16381063

I used your code so the points are yours.  The real problem was I changed my select statement to  - Private scDelInst As String = "SELECT Instruct AS 'Delivery Instructions' from Fontana_Instructions ORDER by Instruct" to change the header on the datagrid without realizing, at the time, it changed the field name.  When I removed the AS part it works fine.  The good news is, I am too new at this to feel stupid. Thanks again for your help.

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month13 days, 16 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question