EXACT重複的Syntax error in INSERT INTO statement in c# oledb?語法錯誤INSERT INTO語句中的c#OleDb的異常不能發現該錯誤
您好我不能發現該錯誤。請幫忙。由於語法錯誤,存在OleDb異常。 INSERT INTO語句中的語法錯誤OleDb異常未處理。
private OleDbConnection myCon;
public Form1()
{
InitializeComponent();
myCon = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C.mdb");
}
private void insertuser_Click(object sender, EventArgs e)
{
try
{
OleDbCommand cmd = new OleDbCommand();
myCon.Open();
cmd.Connection = myCon;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "INSERT INTO User ([UserID], [Forename], [Surname], [DateOfBirth], [TargetWeight], [TargetCalories], [Height]) Values ('" + userid.Text + "' , '" + fname.Text + "' , '" + sname.Text + "' , '" + dob.Text + "' , '" + tarweight.Text + "' , '" + tarcal.Text + "' , '" + height.Text + "')";
cmd.ExecuteNonQuery();
myCon.Close();
}
catch (Exception ex) { MessageBox.Show(ex.ToString()); }
}
你在開玩笑嗎?你能不能告訴我們錯誤是什麼? – 2011-01-07 16:53:28