0
我試圖用下面的代碼將記錄插入到MS Access數據庫中。我在我的項目中多次使用了相同類型的代碼。但我不知道它爲什麼錯誤,說有一個語法錯誤。有人請告訴我代碼出錯的地方。插入到語句中的語法錯誤 - 在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
由於一噸!對此很迷惑...... – sabari