Good morning:
At this moment I am developing a small app in VS.2015 (VB), I have two databases, the first in MySQL and the second in Ms-SQL, both have the same structure, first I make a select and bring the data from a table of each database to a dataset and a datatable, then I make a brief comparison between the datatables, and finally I return the final tab to both databases, when I do it to MS-SQL I have no problem and update , but when I do it to MySQL it does not update, nor does it throw me an error or exception. The code I am using is:
Dim condicion As String = ""
Dim Tabla As String = "Horarios"
'Objects MySql'
Dim conMySql As MySqlConnection
Dim cmdMySql As MySqlCommand
Dim comBMySql As MySqlCommandBuilder
Dim daMySql As MySqlDataAdapter
'Objects Sql'
Dim conSql As SqlConnection
Dim cmdSql As SqlCommand
Dim comSql As SqlCommandBuilder
Dim daSql As SqlDataAdapter
conSql = New SqlConnection(My.Settings.MsSql.ToString)
cmdSql = New SqlCommand("SELECT * FROM " & Tabla & IIf(Condicion <> "", " WHERE " & Condicion, ""), conSql)
daSql = New SqlDataAdapter(cmdSql)
conSql.Open()
cmdSql.ExecuteNonQuery()
daSql.Fill(dsg, Tabla & "1")
conSql.Close()
conMySql = New MySqlConnection(My.Settings.MySqlLocal.ToString)
cmdMySql = New MySqlCommand("SELECT * FROM " & Tabla & IIf(Condicion <> "", " WHERE " & Condicion.Replace("GETDATE", "CURDATE"), ""), conMySql)
daMySql = New MySqlDataAdapter(cmdMySql)
conMySql.Open()
cmdMySql.ExecuteNonQuery()
daMySql.Fill(dsg, Tabla)
conMySql.Close()
Form1.DataGridView1.DataSource = dsg.Tables(Tabla)
Form1.DataGridView2.DataSource = dsg.Tables(Tabla & "1")
dsg.Tables(Tabla).Merge(dsg.Tables(Tabla & "1"))
comBMySql = New MySqlCommandBuilder(daMySql)
Dim upcmdmysql As MySqlCommand
upcmdmysql = New MySqlCommand("UPDATE horarios SET idhorario = ?idhorario, NombreHora = ?NombreHora, Entrada1 = ?Entrada1, Salida1 = ?Salida1, Entrada2 = ?Entrada2, Salida2 = ?Salida2, Observacion = ?Observacion", conMySql)
For Each columna In dsg.Tables(Tabla).Columns
upcmdmysql.Parameters.Add(New MySqlParameter("?" & columna.ToString, columna.GetType))
upcmdmysql.Parameters("?" & columna.ToString).SourceVersion = DataRowVersion.Original
upcmdmysql.Parameters("?" & columna.ToString).SourceColumn = columna.ToString
Next
daMySql.UpdateCommand = upcmdmysql
daMySql.Update(dsg.Tables(Tabla))