ASP.NET 错误提示:必须声明标量变量“@cs” 10
具体代码如下:protectedvoidGridView1_RowCommand(objectsender,GridViewCommandEventArgse){stri...
具体代码如下:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
string crs = GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Value.ToString().Trim();
if (e.CommandName == "xinxi")
{
string cons = @"Data Source=valan\sqlexpress;Initial Catalog=gongchengshijian3;Integrated Security=True;";
SqlConnection con = new SqlConnection(cons);
con.Open();
SqlCommand com = new SqlCommand();
com.Connection = con;
com.CommandType = CommandType.Text;
string sql = "select 信息编号,主题,发布人,发表日期 from xinxi where 课程编号=@cs";
SqlDataAdapter da = new SqlDataAdapter(sql, con);
new SqlParameter("@cs", crs);
DataSet ds = new DataSet();
da.Fill(ds);
GridView2.DataSource = ds.Tables[0];
GridView2.DataBind();
con.Close();
}
}
求大神指导该怎么改 展开
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
string crs = GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Value.ToString().Trim();
if (e.CommandName == "xinxi")
{
string cons = @"Data Source=valan\sqlexpress;Initial Catalog=gongchengshijian3;Integrated Security=True;";
SqlConnection con = new SqlConnection(cons);
con.Open();
SqlCommand com = new SqlCommand();
com.Connection = con;
com.CommandType = CommandType.Text;
string sql = "select 信息编号,主题,发布人,发表日期 from xinxi where 课程编号=@cs";
SqlDataAdapter da = new SqlDataAdapter(sql, con);
new SqlParameter("@cs", crs);
DataSet ds = new DataSet();
da.Fill(ds);
GridView2.DataSource = ds.Tables[0];
GridView2.DataBind();
con.Close();
}
}
求大神指导该怎么改 展开
大雅新科技有限公司
2024-11-19 广告
2024-11-19 广告
这方面更多更全面的信息其实可以找下大雅新。深圳市大雅新科技有限公司从事KVM延长器,DVI延长器,USB延长器,键盘鼠标延长器,双绞线视频传输器,VGA视频双绞线传输器,VGA延长器,VGA视频延长器,DVI KVM 切换器等,优质供应商,...
点击进入详情页
本回答由大雅新科技有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询