郁闷

xiaoming851 xiaoming851 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
private void DataGrid1_ItemDataBound_1(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(!i)
{
e.Item.Cells[3].Text = "测试";
}
else
{
string CommandText = "select count(*) as count from zrbhdetail where parent=" + e.Item.Cells[0].Text;
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["conn"]);
SqlCommand Command = new SqlCommand(CommandText, myConnection);
myConnection.Open();
int total = (int)Command.ExecuteScalar();
myConnection.Close();
// return total.ToString();
e.Item.Cells[3].Text = total.ToString();
// e.Item.Cells[3].Text = GetCount(e.Item.Cells[0].Text);
}
i=true;
}


错误:
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Data.SqlClient.SqlException: 第 1 行: '&' 附近有语法错误。

源错误:


行 87: SqlCommand Command = new SqlCommand(CommandText, myConnection);
行 88: myConnection.Open();
行 89: int total = (int)Command.ExecuteScalar();
行 90: myConnection.Close();
行 91: // return total.ToString();

...全文
评论 19
收藏 已收藏
分享
返回顶部
xiaoming851
.NET社区 62,272 成员 668,968 内容