ajout dans BD MySql avec VB 2008
Salut à tous
J'ai un probléme concernant l'ajout des champs dans une base de donnée MySql via vb 2008.
Voilà le code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Then
MessageBox.Show("Il faut remplir tout les champs")
Else
state = StateEnum.StateNew
Select state
Case Is = StateEnum.StateNew 'Ajouter un record
Dim MyNewRow As DataRow = dst.Tables("caract").NewRow
Try
MyNewRow("id_p") = TextBox1.Text
MyNewRow("nom") = TextBox2.Text
MyNewRow("prenom") = TextBox2.Text
MyNewRow("Nom utilisateur") = TextBox3.Text
MyNewRow("Mot de passe") = TextBox2.Text
dst.Tables("cract").Rows.Add(MyNewRow)
Dim MyCommBuild As New MySqlCommandBuilder(da)
da.Update(dst, "cract")
Catch err As Exception
MsgBox(err.Message, MsgBoxStyle.Exclamation, "error")
Exit Sub
End Try
End Select
End If
End Sub |
Le problème est dans la ligne en rouge. Cela indique erreur :
Citation:
La référence d'objet n'est pas définie à une instance d'un objet
Merci de m'aider s'il vous plait.