System.Data.SqlClient.SqlException (0x80131904): 必须声明标量变量
.net事件代码protectedvoidButton1_Click(objectsender,EventArgse){{if(Session["uname"]==nul...
.net 事件代码
protected void Button1_Click(object sender, EventArgs e)
{
{
if (Session["uname"] == null)
{
Label17.Text = "请先登陆!";
}
else
{
Label18.Text ="我选中了"+txtDate.Text+" "+DropDownList3.Text+" "+"场地"+DropDownList1.Text;
try
{
string str = ConfigurationManager.ConnectionStrings["SufeelConnectionString"].ToString();
SqlConnection con = new SqlConnection(str);
con.Open();
SqlCommand cmd = new SqlCommand();
string strsql = "select * from [order] where [cid] =@c and [date] = @d and [start_time] = @t";
cmd.CommandText = strsql;
cmd.Connection = con;
cmd.Parameters.Add("@c",SqlDbType.NVarChar).Value= DropDownList1.SelectedValue.ToString();
cmd.Parameters.Add("@d",SqlDbType.Date).Value = DateTime.Parse(txtDate.Text).Date;
cmd.Parameters.Add("@t",SqlDbType.NVarChar).Value= DropDownList3.SelectedValue.ToString();
SqlDataAdapter da = new SqlDataAdapter(strsql, con);
DataSet ds = new DataSet();
int count = da.Fill(ds, "order");
if (count > 0)
{
Label17.Text = "该场地已经预约";
}
else
{ strsql = "INSERT INTO [order] (uname,cid,date,start_time,paid) VALUES('"+Session["uname"]+"',@c,@d,@t,N)";
cmd.ExecuteNonQuery();
Label17.Text = "已成功预约请尽快付款。";
}
}
catch (Exception ee)
{
Label8.Text = ee.ToString();
}
}
}
} 展开
protected void Button1_Click(object sender, EventArgs e)
{
{
if (Session["uname"] == null)
{
Label17.Text = "请先登陆!";
}
else
{
Label18.Text ="我选中了"+txtDate.Text+" "+DropDownList3.Text+" "+"场地"+DropDownList1.Text;
try
{
string str = ConfigurationManager.ConnectionStrings["SufeelConnectionString"].ToString();
SqlConnection con = new SqlConnection(str);
con.Open();
SqlCommand cmd = new SqlCommand();
string strsql = "select * from [order] where [cid] =@c and [date] = @d and [start_time] = @t";
cmd.CommandText = strsql;
cmd.Connection = con;
cmd.Parameters.Add("@c",SqlDbType.NVarChar).Value= DropDownList1.SelectedValue.ToString();
cmd.Parameters.Add("@d",SqlDbType.Date).Value = DateTime.Parse(txtDate.Text).Date;
cmd.Parameters.Add("@t",SqlDbType.NVarChar).Value= DropDownList3.SelectedValue.ToString();
SqlDataAdapter da = new SqlDataAdapter(strsql, con);
DataSet ds = new DataSet();
int count = da.Fill(ds, "order");
if (count > 0)
{
Label17.Text = "该场地已经预约";
}
else
{ strsql = "INSERT INTO [order] (uname,cid,date,start_time,paid) VALUES('"+Session["uname"]+"',@c,@d,@t,N)";
cmd.ExecuteNonQuery();
Label17.Text = "已成功预约请尽快付款。";
}
}
catch (Exception ee)
{
Label8.Text = ee.ToString();
}
}
}
} 展开
1个回答
威孚半导体技术
2024-08-19 广告
2024-08-19 广告
威孚(苏州)半导体技术有限公司是一家专注生产、研发、销售晶圆传输设备整机模块(EFEM/SORTER)及核心零部件的高科技半导体公司。公司核心团队均拥有多年半导体行业从业经验,其中技术团队成员博士、硕士学历占比80%以上,依托丰富的软件底层...
点击进入详情页
本回答由威孚半导体技术提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询