异常详细信息: System.Data.SqlClient.SqlException: 必须声明标量变量 "@sxh".
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSys...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Data;
using System.Data.SqlClient;
public partial class insert : System.Web.UI.Page
{
string sql = WebConfigurationManager.AppSettings ["myconn"];
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btntj_Click(object sender, EventArgs e)
{
string sxh = this.tbx_ID.Text;
string sxm = this.tbx_xm.Text;
string sxb = RadioButtonList1.SelectedItem.Text;
string szy = DropDownList1.SelectedItem.Text;
string scsrq = this.tbx_csrq.Text;
string sdk; if (CheckBox1.Checked)
{
sdk = "是";
}
else sdk = "否";
string ssfz = this.tbx_sfz.Text;
string sjg = this.tbx_jg.Text;
string sjtdz = this.tbx_jtdz.Text;
SqlConnection conn = new SqlConnection(sql);
string da = "insert into xsdate(ID,xm,xb,zy,csrq,dk,sfz,jg,jtdz) values(@sxh,@sxm,@sxb,@szy,@scsrq,@sdk,@ssfz,@sjg,@sjtdz)";
SqlCommand cmd = new SqlCommand (da ,conn );
conn.Open();
if (cmd.ExecuteNonQuery() > 0)
{
Response.Write("添加成功");
}
cmd.Prepare();
conn .Close (); 展开
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Data;
using System.Data.SqlClient;
public partial class insert : System.Web.UI.Page
{
string sql = WebConfigurationManager.AppSettings ["myconn"];
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btntj_Click(object sender, EventArgs e)
{
string sxh = this.tbx_ID.Text;
string sxm = this.tbx_xm.Text;
string sxb = RadioButtonList1.SelectedItem.Text;
string szy = DropDownList1.SelectedItem.Text;
string scsrq = this.tbx_csrq.Text;
string sdk; if (CheckBox1.Checked)
{
sdk = "是";
}
else sdk = "否";
string ssfz = this.tbx_sfz.Text;
string sjg = this.tbx_jg.Text;
string sjtdz = this.tbx_jtdz.Text;
SqlConnection conn = new SqlConnection(sql);
string da = "insert into xsdate(ID,xm,xb,zy,csrq,dk,sfz,jg,jtdz) values(@sxh,@sxm,@sxb,@szy,@scsrq,@sdk,@ssfz,@sjg,@sjtdz)";
SqlCommand cmd = new SqlCommand (da ,conn );
conn.Open();
if (cmd.ExecuteNonQuery() > 0)
{
Response.Write("添加成功");
}
cmd.Prepare();
conn .Close (); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询