我正在将记录插入数据库,但在“参数”日期中出现错误。任何想法都会很好。
myConnection.Open()
Dim sqlQry As String = "INSERT INTO MasterLabNumber (LabNumber, Location, Date)" + "VALUES(@LabNumber, @Location, @Date)"
Dim str As String
str = "SELECT * FROM MasterLabNumber WHERE (LabNumber = " & TextBox1.Text & ")"
Dim d As System.DateTime = DateTime.Now.ToString("yyyy/MM/dd")
Dim cmd As OleDbCommand = New OleDbCommand(sqlQry, myConnection)
cmd.Parameters.AddWithValue("@LabNumber", TextBox1.Text)
cmd.Parameters.AddWithValue("@Location", ComboBox1.Text)
cmd.Parameters.AddWithValue("@Date", d)
cmd.ExecuteNonQuery() <-- gets error here relating to adding the parameter date.
答案 0 :(得分:2)
是的,原因const BLOCK_1: () = {
mod inner {
extern crate anymap;
use self::anymap::AnyMap;
}
};
是您在insert语句中使用的保留字。你需要使用Date
[]
您的插入声明应该变为
INSERT INTO MasterLabNumber (LabNumber, Location, [Date])