mise à jour dataset vers la base mysql
Bonjour,
je viens à vous pour une question qui me taraude. J'ai un dataset pour lequel je charge mes différentes tables. Lorsque j'ajoute une row supplémentaire dans une de mes tables
et que je répercute sur la base de donnée, je doit définir la selectCommand de mon MySqlDataAdapter. Je ne comprend pas ce point.
Si cela peut vous aider voici la manière dont je m'y prend :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
Public Sub InsertNcMapg(inst As String, anne As String, gestio As Long, keyMarche As Long, marSeq As Long, modServ As String, boncCod As String, boncSta As String)
Try
dataBase.Tables("ncmapg").Rows.Add(inst, anne, gestio, keyMarche, marSeq, modServ, boncCod, boncSta)
InsertDataTable("ncmapg")
Catch ex As Exception
End Try
End Sub
Private Sub InsertDataTable(ByVal tableToUpdate As String)
Dim sqlAdapter As MySqlDataAdapter = New MySqlDataAdapter("SELECT * FROM " & tableToUpdate, sqlConnexion)
Dim sqlCommandBuilder As MySqlCommandBuilder = New MySqlCommandBuilder(sqlAdapter)
Try
sqlAdapter.InsertCommand = sqlCommandBuilder.GetInsertCommand
'sqlAdapter.UpdateCommand = sqlCommandBuilder.GetUpdateCommand()
sqlAdapter.Update(dataBase, tableToUpdate)
dataBase.AcceptChanges()
Catch ex As Exception
End Try
End Sub |
J'espère que vous pourrez m'apporter une réponse clair.
D'avance merci.