[Vb.net] DataSet problème
Voici le problème. lorsque cette partie du code s'exécute, Mon premier accès a miseAJour("educatrice") fonctionne et ma base de donné est modifié. Cependant, lorsque le 2ieme se fait, miseAJour("seq") je recoiçois ce message d'erreur."DataColumn 'noEducatrice' manquant dans DataTable 'seq' pour SourceColumn 'noEducatrice'." Si je met en commentaire miseAJour("educatrice"), la méthode miseAJour("seq") ne fait aucune erreur et la base de donnée se met a jour. Une idée comment règler ce problème?
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 32 33
|
'
'Sauvegarde de la nouvelle éducatrice dans la base de donnée
'
Sub insert(ByVal educatrice As Educatrice)
command = New SqlClient.SqlCommand("select * from educatrice;")
command.Connection = cnSql
command.CommandType = CommandType.Text
dataAdapter.SelectCommand = command
seqEducatrice += 1
Dim row As DataRow = dataSet.Tables("educatrice").NewRow
row.Item(0) = seqEducatrice
row.Item(1) = educatrice.getNom
row.Item(2) = educatrice.getPrenom
row.Item(3) = educatrice.getDateEmbauche
row.Item(4) = educatrice.getFormation
row.Item(5) = educatrice.getheureReconnu
row.Item(6) = educatrice.getTelephone
dataSet.Tables("educatrice").Rows.Add(row)
miseAJour("educatrice")
noEducatrice()
End Sub
'
'Sauvegarde de la séquence educatrice
'
Sub noEducatrice()
command = New SqlClient.SqlCommand("select * from seq;")
command.Connection = cnSql
command.CommandType = CommandType.Text
dataAdapter.SelectCommand = command
dataSet.Tables("seq").Rows(0).Item(1) = seqEducatrice
miseAJour("seq")
End Sub |
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
'permet la mise à jour de la base de donnée avec un dataSet
Sub miseAJour(ByVal nomTable As String)
Try
dataAdapter.Update(dataSet, nomTable)
dataAdapter.Dispose()
'dataSet.AcceptChanges()
MsgBox("Modification terminer")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub |