Problème UPDATE table d'une base SQL
Bonjour, je rencontre un problème lors de l'UPDATE de ma base SQL, j'obtiens un message d'erreur "La propriété ConnectionString n'a pas été initialisée"
Comme je suis débutant, je me suis largement inspiré de l'aide et de codes trouvés sur internet, mais là je n'arrive pas à comprendre d'où vient ce problème.
Voici mon 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 27 28 29 30 31
| Private Sub CréerButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CréerButton.Click
'Ajout du nouveau patient
Dim NewPatientRow As DataRow = GestionPatientsDataSet.Tables("Patient").NewRow
NewPatientRow.Item(columnName:="NuméroPatient") = NuméroTextBox.Text
NewPatientRow.Item(columnName:="NomComplet") = String.Concat(NomTextBox.Text, " ", PrénomTextBox.Text)
NewPatientRow.Item(columnName:="Nom") = NomTextBox.Text
NewPatientRow.Item(columnName:="Prénom") = PrénomTextBox.Text
NewPatientRow.Item(columnName:="Tech") = TechComboBox.Text
NewPatientRow.Item(columnName:="Présent") = True
GestionPatientsDataSet.Tables("Patient").Rows.Add(NewPatientRow)
'Définition chaine de connection
Dim connectstring0 = String.Concat("Data Source=MBACedric\SQLEXPRESS;Initial Catalog=TestGestionPatients;User ID=", IdentifiantSQL, ";PWD=", IdentifiantSQL)
Dim connectstring = String.Concat(connectstring0, ";Pwd=", PasswordSQL, ";Persist Security Info=False")
ObjetCommandBuilder = New SqlClient.SqlCommandBuilder(GestionPatientsAdapter)
'Procédure d'ouverture de la connexion
Using connect As New SqlClient.SqlConnection(connectstring)
Try
'Ouverture connexion
connect.Open()
'Mise à jour Base Sql
GestionPatientsAdapter.Update(GestionPatientsDataSet, "Patient")
Catch ex As Exception
'Affichage du message d'erreur
MessageBox.Show("L'erreur suivante a été rencontrée :" & ex.Message)
End Try
End Using
End Sub |