SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=resterant;Integrated Security=True");
SqlCommand com = new SqlCommand("INSERT INTO [order](tableNo,order,price) VALUES (@tableNo,@order,@price)", con);
SqlParameter param = new SqlParameter();
SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=resterant;Integrated Security=True");
SqlCommand com = new SqlCommand("INSERT INTO [order](tableNo,order,price) VALUES (@tableNo,@order,@price)", con); SqlParameter param = new SqlParameter();
com.Parameters.Add("@tableNo", SqlDbType.NVarChar).Value = label2.Text;
com.Parameters.Add("@order", SqlDbType.NVarChar).Value = label3.Text;
com.Parameters.Add("@price", SqlDbType.Int).Value = int.Parse(label5.Text); //<-- convert parameter value from a String to a Int32.
ต้องมั่นใจว่า label5.Text มีค่าจริงๆ นะ แล้ว สามารถ convert เป็น int ได้ด้วย
Date :
2010-01-27 11:04:34
By :
numenoy
No. 3
Guest
SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=resterant;Integrated Security=True");
SqlCommand com = new SqlCommand("INSERT INTO [order](tableNo,order,price) VALUES (@tableNo,@order,@price)", con);
com.Parameters.Add("@tableNo", SqlDbType.NVarChar).Value = label2.Text;
com.Parameters.Add("@order", SqlDbType.NVarChar).Value = label3.Text;
com.Parameters.Add("@price", SqlDbType.Int).Value = int.Parse(label5.Text); //<-- convert parameter value from a String to a Int32.
con.Open(); com.ExecuteNonQuery();
ที่ขีดเส้นใต้มันerror อีกแล้วค่ะ
ERROR >>>> Incorrect syntax near the keyword 'order'.