我收到了这个错误:
语法错误 INSERT INTO 语句
这是正确的另一个是 SQL 对不起
//Server Connection
private void ServerConnect()
{
string ConnString;
ConnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=PLAN.accdb";
TConn = new OleDbConnection(ConnString);
TConn.Open();
MessageBox.Show("You Are Connected.");
TConn.Close();
}
//ADD MEMOS
private void GetMemoList()
{
string query;
DataSet ds = new DataSet();
query = "SELECT MEMO_ID,DATE,TIME,MEMOS FROM TBLMEMO ORDER BY DATE ASC";
OleDbDataAdapter da = new OleDbDataAdapter(query, TConn);
da.Fill(ds);
this.dgv1.DataSource = ds.Tables[0];
}
private void AddMemo(string MemoDate, string MemoTime, string Memos)
{
TConn.Open();
string acc;
acc = "INSERT INTO TBLMEMO (DATE,TIME,MEMOS) VALUES (@Memodate,@MemoTime,@Memos)";
OleDbCommand cmd = new OleDbCommand(acc, TConn);
cmd.Parameters.AddWithValue("@memDate", MemoDate);
cmd.Parameters.AddWithValue("@memTime", MemoTime);
cmd.Parameters.AddWithValue("@memos", Memos);
cmd.ExecuteNonQuery();
TConn.Close();
}
private void btnAddMemos_Click(object sender, EventArgs e)
{
AddMemo(this.dtpDate.Value.ToShortDateString(), this.dtpTime.Value.ToShortTimeString(), this.txtInfo.Text.Trim());
GetMemoList();
txtInfo.Clear();
}