Bonjour,
J'utilise un adaptater pour mettre à jour une base access.
Cela marche très bien pour la suppression mais pas l'insertion, j'ai une erreur de la forme "Erreur de syntaxe dans INSERT INTO"
Y-a-t-il un moyen d'avoir plus d'info sur le message d'erreur ?Try
MyConnexion.Open()
' Création CommandBuilder
'(genere automatiquement l'update entre le dataSet et la base de donnée
Dim CmdBuild As New OleDb.OleDbCommandBuilder(Adapter)
Adapter.UpdateCommand = CmdBuild.GetUpdateCommand()
'Adapter.DeleteCommand = CmdBuild.GetDeleteCommand
'Adapter.InsertCommand = CmdBuild.GetInsertCommand
Adapter.Update(ObjetDataSet, table)
MyConnexion.Close()
Catch ex As OleDbException
MsgBox(ex.Message & ex.ErrorCode)
MyConnexion.Close()
End Try
Pour l'instant j'arrive à contourner le problème en passant des commandes
Merci d'avanceDim Mycommand As OleDbCommand = MyConnexion.CreateCommand()
Mycommand.CommandText = "INSERT INTO IMAGES([Image], [Commentaire]) VALUES (?, ?)"
MyConnexion.Open()
Mycommand.Parameters.Add(New OleDbParameter("Image", OleDbType.VarBinary, bytImage.Length, ParameterDirection.Input, False, CByte(0), CByte(0), "", DataRowVersion.Current, bytImage))
Mycommand.Parameters.Add(New OleDbParameter("Commentaire", System.Data.OleDb.OleDbType.VarWChar, 50, ParameterDirection.Input, False, CByte(0), CByte(0), "", DataRowVersion.Current, commentaire))
Mycommand.ExecuteNonQuery()
MyConnexion.Close()
Partager