Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

problem saving datagridview back to mysql vb.net

Avatar of Steven Debock
Steven Debock asked on
MySQL Server.NET ProgrammingVisual Basic.NET
4 Comments1 Solution720 ViewsLast Modified:
Hy,

I can load the db into the datagridview.
i'm trying to save changes made in the datagridview to be stored back to the mysql db.
But i'm not getting any errors and its not saving.

Any id ?

vb.net vs 2008
Public Class Form1
    Dim connetionString As String
    Dim connection As MySqlConnection
    Dim adapter As MySqlDataAdapter
    Dim cmdBuilder As MySqlCommandBuilder
    Dim ds As New DataSet
    Dim changes As DataSet
    Dim sql As String
    Dim i As Int32

Private Sub BekijkAllesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BekijkAllesToolStripMenuItem.Click
        Dim connetionString As String = ("Data Source=site;Initial Catalog=catalog;User ID=id;Password=pw")

        connection = New MySqlConnection(connetionString)
        sql = "select * from Herstellingen2"
        Try
            connection.Open()
            adapter = New MySqlDataAdapter(sql, connection)
            adapter.Fill(ds)
            connection.Close()
            Herstellingen.DataSource = ds.Tables(0)
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

    Private Sub SaveToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripButton.Click
        Try
            cmdBuilder = New MySqlCommandBuilder(adapter)
            changes = ds.GetChanges()
            If changes IsNot Nothing Then
                adapter.Update(changes)
            End If
            MsgBox("Opgeslagen")
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
ASKER CERTIFIED SOLUTION
Avatar of Shahan Ayyub
Shahan AyyubFlag of Pakistan imageStaff Software Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answers