0
當我想從文本框向我的訪問數據庫插入值時,出現問題! 當我要救我得到這個錯誤(「標準表達式中數據類型不匹配」) 代碼:「標準表達式中的數據類型不匹配」
string conString = "Provider=Microsoft.Jet.OLEDB.4.0;"
+ "Data Source=C:\\Users\\Simon\\Desktop\\test5\\test5\\test5\\save.mdb";
OleDbConnection empConnection = new OleDbConnection(conString);
string insertStatement = "INSERT INTO aktivnosti_save "
+ "([ID_uporabnika],[ID_aktivnosti],[kalorij]) "
+ "VALUES (@ID_uporabnika,@ID_aktivnosti,@kalorij)";
OleDbCommand insertCommand = new OleDbCommand(insertStatement, empConnection);
insertCommand.Parameters.Add("@ID_uporabnika", OleDbType.Char).Value = textBox3.Text;
insertCommand.Parameters.Add("@ID_zivila", OleDbType.Char).Value = iDTextBox.Text;
insertCommand.Parameters.Add("@kalorij", OleDbType.Char).Value = textBox2.Text;
empConnection.Open();
try
{
int count = insertCommand.ExecuteNonQuery();
}
catch (OleDbException ex)
{
MessageBox.Show(ex.Message);
}
finally
{
empConnection.Close();
textBox1.Clear();
textBox2.Clear();
}
}
這看起來像是重複的http://stackoverflow.com/questions/2731216/problems-by-inserting-values-from-textboxes – Thomas 2010-05-02 14:36:27
他們都是絕對字符數據不是數字?包括ID字段ID_zivila和@ID_uporabnika? – 2010-05-02 14:38:19
@Thomas - 略有不同的查詢,但似乎是根本相同的問題! – 2010-05-02 14:42:18