Update table from datagrid

Posted on 2006-04-04
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

    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
    LVL 5

    Author Comment


    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now