【发布时间】:2019-11-10 03:46:57
【问题描述】:
当我的 SQL 字符串带有条件字符串时,我无法在 asp.net 的 Grid-view 上显示我的表格
我有 color 类型是 varchar(4) 在我的 SQL 字符串连接中,它无法在我的代码上运行 在我的代码中显示颜色时看不到表格 错误部分=>color'"+blue+"' 它不起作用
protected void BindData()
{
DataSet ds;
string SQL = "";
SQL = ("select id from table where color='"+blue+"'");
ds = CreateDataSource(string.Format("exec P_PageData '{0}',{1},{2}", SQL, this.SplitPage1.CurrentPage, this.SplitPage1.PageSize));
if (ds != null && ds.Tables.Count == 3)
{
this.SplitPage1.CurrentPage = Convert.ToInt32(ds.Tables[1].Rows[0]["CurPage"]);
this.SplitPage1.TotalRecorder = Convert.ToInt32(ds.Tables[1].Rows[0]["Total"]);
this.rptPremissionList.DataSource = ds.Tables[2];
this.rptPremissionList.DataBind();
}
}
如果 blur(string) 在代码中,它不起作用
如果我用其他人替换它INT column
它可以工作
如果是一串条件,请帮我解决它
【问题讨论】:
-
替换字符串列无效
标签: c# sql string select connection-string