title: Updating/Saving Information to MySQL Database from Datagrid MDI
body: <p>I've got a bit of an odd one, I've been looking online but cannot find anything specific to my issue. Hopefully someone could help me.</p>
  
  <p>I have a VB.Net 2012 application that reads information from MySQL. The reading is fine and it populates correctly but I am having trouble working out how to save changes back.</p>
  
  <p>The information is displayed from a DataTable into a DataGridView. The application is an MDI application and at anygiven point there could be more than one TableEditor Form Open as a Child.</p>
  
  <p>This is my information loading function:</p>
  
  <pre><code>    Public Function get_SQL(ByVal SQLquery As String) As DataTable
      Try
          Dim myCommand As New MySqlCommand
          Dim myAdapter As New MySqlDataAdapter
          Dim myData As New DataTable
          Dim MysqlConn As New MySqlConnection
  
          MysqlConn.ConnectionString = "server=" &amp; sqlServer &amp; ";" _
              &amp; "user id=" &amp; sqlUsername &amp; ";" _
              &amp; "password=" &amp; sqlPassword &amp; ";" _
              &amp; "database=" &amp; sqlDatabase
  
          MysqlConn.Open()
          myCommand.Connection = MysqlConn
          myCommand.CommandText = SQLquery
          myAdapter.SelectCommand = myCommand
          myAdapter.Fill(myData)
          MysqlConn.Close()
          MysqlConn.Dispose()
          Return (myData)
      Catch ex As Exception
          Main.lblStatus.Text = "SQL Connection Error"
          errMsg = ex.ToString
          errForm = "SQL Connection"
          errWrite()
      End Try
  End Function
  </code></pre>
  
  <p>And the information is loaded into the child form on load like this:</p>
  
  <pre><code>    Private Sub SQLeditor_Load(sender As Object, e As EventArgs) Handles Me.Load
      ToolStrip1.Visible = False
      Select Case sqlclick
          Case Is = "Office Details"
              SQLdata = get_SQL(qryOffice)
          Case Is = "School Details"
              SQLdata = get_SQL(qrySchools)
          Case Is = "ICT Staff"
              SQLdata = get_SQL(qryITstaff)
          Case Else
              ToolStrip1.Visible = True
      End Select
      dgvEditor.DataSource = SQLdata
  End Sub
  </code></pre>
  
  <p>SQLdata is a global variable "Public SQLdata As DataTable"</p>
  
  <p>So I want to create a new Function that will save any changes back to the SQL database. As I am using the same global variable to populate a single form with multiple instances that can exist simultaneously I need to work out how to pass the information from the DataGridView or something along those lines and I'm stuck.</p>
  
  <p>Any help is much appreciated.</p>