asp.net怎么获取数据库中符合条件记录的行数并赋值?
SqlConnectionsqlConn=newSqlConnection();sqlConn.ConnectionString="server=.\\sqlexpres...
SqlConnection sqlConn = new SqlConnection();
sqlConn.ConnectionString = "server= .\\sqlexpress;Initial Catalog=P;Integrated Security=True";
sqlConn.Open();
string selectStr = "select count(*) from allrecords where month='" + month + "' AND year='" + year + "' ";
SqlCommand select = new SqlCommand(selectStr, sqlConn);
int l = (int)select.ExecuteScalar();
sqlConn.Close();
l是获取的符合条件的记录行数吗?运行起来结果是错误的,求指正。谢谢。 展开
sqlConn.ConnectionString = "server= .\\sqlexpress;Initial Catalog=P;Integrated Security=True";
sqlConn.Open();
string selectStr = "select count(*) from allrecords where month='" + month + "' AND year='" + year + "' ";
SqlCommand select = new SqlCommand(selectStr, sqlConn);
int l = (int)select.ExecuteScalar();
sqlConn.Close();
l是获取的符合条件的记录行数吗?运行起来结果是错误的,求指正。谢谢。 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询