刚入道请求指点
在下是一名刚入.NET道的新手,作了一个表单数据提交到SQL数据库中,在运行提交时代码反应出问题:protected void Submit_btn_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog=DB_SH.mdf;Integrated Security=True;User Instance=True";
SqlCommand cmd = new SqlCommand();
= "INSERT INTO td_Order(OrderName,OrderCount,CompanyName,ReceiverPhone,ReceiverName,ReceiverFax,Address,ReceiverPostCode,Email,CompanyUrl,ReceiverRequest,OrderDate) VALUES(" + this.ProdustName.Text + ",'" + this.Count.Text + "','" + + "','" + this.Phone.Text + "','" + this.People.Text + "','" + this.Fax.Text + "','" + this.Address.Text + "','" + this.PostCode.Text + "','" + this.Email.Text + "','" + + "','" + this.Content.Text + "','" + DateTime.Now + "')";
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();//出现问题了---在此上下文中不允许使用名称 "xx"。有效表达式包括常量、常量表达式和变量(在某些上下文中)。不允许使用列名。
con.Close();
SqlData da = new SqlData();
bool add = da.ExceSQL();
if (add == true)
{
Response.Write("<script type=\"text/javascript\">alert('添加成功!');location='Order.aspx'</script>");
}
else
{
Response.Write("<script type=\"text/javascript\">alert('添加失败!');location='javascript:history.go(-1)'</script>");
}
}
如何处理呢,谢谢急!!!