J'essaie d'insérer un enregistrement dans MS Access db, avec le code ci-dessous. J'ai utilisé le même type de code plusieurs fois dans mon projet. Mais je ne sais pas pourquoi c'est une erreur, en disant qu'il y a une erreur de syntaxe. Quelqu'un s'il vous plaît me suggérer où le code est erroné.Erreur de syntaxe dans insert into statement - in VB.NET
Try
If MainForm.con.State = ConnectionState.Closed Then
MainForm.con.Open()
End If
Dim cmdText As String
cmdText = "insert into tblBottling(bottlingDate,workerName,seed,size,noOfBottles,timeTaken,remarks) values(?,?,?,?,?,?,?)"
Dim command As OleDbCommand = New OleDbCommand(cmdText, MainForm.con)
command.Parameters.AddWithValue("@bottlingDate", botDate.Value.ToString("dd-MM-yy"))
command.Parameters.AddWithValue("@workerName", workerCB.SelectedItem.ToString)
command.Parameters.AddWithValue("@seed", seedCB.SelectedItem.ToString)
command.Parameters.AddWithValue("@size", botSizeCB.SelectedItem.ToString)
command.Parameters.AddWithValue("@noOfBottles", CInt(noOfBot.Text))
command.Parameters.AddWithValue("@timeTaken", timeTakenTxt.Text)
command.Parameters.AddWithValue("@remarks", remarksTxt.Text)
command.ExecuteNonQuery()
MainForm.con.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Merci une tonne! Était tellement confus avec ça ... – sabari