连接字符串int asp错误
本文关键字:错误 asp int 字符串 连接 | 更新日期: 2023-09-27 18:27:03
我在第20行有错误,这是错误行:
int temp = Convert.ToInt32(com.ExecuteScalar().ToString());
我的代码页面:粘贴
显示的页面错误:粘贴
错误显示:
字符串"后面的引号未闭合。
您的SQL命令是:
string checkuser = "select count(*)
from SystemMemberInfo
where Username="+ TextBoxUserName.Text +"'";
如果您查看字符串,您会注意到WHERE子句的末尾有一个引号,而不是开头。
您的WHERE子句应该更像:
where Username='"+ TextBoxUserName.Text +"'";
也请不要进行这样的查询,它们很容易受到SQL注入攻击。
您的错误出现在SQL查询where
语句上。
您的代码是:
string checkuser = "select count(*) from SystemMemberInfo where Username="+ TextBoxUserName.Text +"'";
要纠正它,可以这样写:
string checkuser = "select count(*) from SystemMemberInfo where Username='" + TextBoxUserName.Text + "'";