我正在尝试存储查询字符串的结果
q = "select count(*) from test" (asp.net c#)
在字符串变量中,以便我可以在按钮单击时在标签上显示计数。
我正在尝试存储查询字符串的结果
q = "select count(*) from test" (asp.net c#)
在字符串变量中,以便我可以在按钮单击时在标签上显示计数。
int RecordCount;
RecordCount = Convert.ToInt32(cmd.ExecuteScalar());
string myString = RecordCount.ToString();
ExecuteScalar的值可以是 null,请确保检查 null
int RecordCount = 0;
object retVal = cmd.ExecuteScalar();
if(retVal != null)
RecordCount = Convert.ToInt32(cmd.ExecuteScalar());