标题:刚入道请求指点
只看楼主
孙行者
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2008-8-26
 问题点数:0 回复次数:0 
刚入道请求指点
在下是一名刚入.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>");
            }
    }
如何处理呢,谢谢急!!!
搜索更多相关主题的帖子: 请求 
2008-08-26 16:06



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-229941-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.592083 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved