我又回来了。 我之前问过一个类似的问题,但即使在上一个答案的帮助下并用问号尝试它,或者我尝试过 AddWithValue 而不是 AddWithValue 我没有任何运气。
我试图将 txt_Naam 更改为 txt_Naam.Text,没有。
还把 [] 放在列名周围,没有运气。它不断给我这个“INSERT INTO 语句中的语法错误。”。
这次我用下面的代码一无所获。可能是小东西,但我无法弄清楚。(再次...)
protected void btn_final_Click(object sender, EventArgs e)
{
string fact_adres = txt_Naam.Text + "," + txt_Anaam.Text + "," + txt_Adres.Text + "," + txt_Toevoeg.Text + "," + txt_Pcode.Text + "," + txt_Plaats.Text + "," + txt_Email.Text ;
string fact_adres1 = txt_Naam1.Text + "," + txt_Anaam1.Text + "," + txt_Adres1.Text + "," + txt_Toevoeg1.Text + "," + txt_Pcode1.Text + "," + txt_Plaats1.Text + "," + txt_Email1.Text;
string a = "1";
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; "
+ "Data Source=|DataDirectory|webwinkel.accdb";
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = conn;
cmd.CommandText = "INSERT INTO Order (factuur_adres_id, verzend_adres_id, totaalprijs) VALUES (?, ?, ?);";
cmd.Parameters.Add("@factuur_adres", OleDbType.VarChar, 125).Value = fact_adres;
cmd.Parameters.Add("@verzend_adres", OleDbType.VarChar, 125).Value = fact_adres1;
cmd.Parameters.Add("@totaal_prijs", OleDbType.VarChar, 7).Value = a;
try
{
conn.Open();
OleDbDataReader reader = cmd.ExecuteReader();
reader.Close();
}
catch (Exception exc)
{
Label1.Text = exc.Message;
}
finally
{
conn.Close();
Session["Winkelwagen"] = null;
}
}