2014-10-17 92 views
-4

我在这里20行错误是错误行:连接字符串INT ASP错误

int temp = Convert.ToInt32(com.ExecuteScalar().ToString());

页面我的代码:Pastebin

页错误显示:Pastebin

+0

什么是com.ExecuteScalar()的'值的ToString()'和你有什么'CurrentCulture'?请在此处将您的代码和错误消息显示为文本。由于我现在在工作,因此pastebin域被防火墙阻止。 – 2014-10-17 13:00:27

+0

它告诉你到底发生了什么错误:'在字符串''之后未使用引号' – Jonesopolis 2014-10-17 13:02:22

+0

尝试解决您的选择,如下所示:'从SystemMemberInfo中选择count(*),其中Username ='“+ TextBoxUserName.Text +”'“ ;' – 2014-10-17 13:02:31

回答

4

错误说:

字符stri之后未封闭的引号ng''。

你的SQL命令是:

string checkuser = "select count(*) 
        from SystemMemberInfo 
        where Username="+ TextBoxUserName.Text +"'"; 

如果你看一下你的字符串,你会发现,你在你的WHERE子句的末尾有一个引号,而不是在开头。

你的WHERE子句应该更像:

where Username='"+ TextBoxUserName.Text +"'"; 

这样也请不要做查询,他们很容易受到SQL Injection attacks

+0

Nope http://pastebin.com/iDCEwp9U – 2014-10-17 13:16:06

+0

@herobrinebrotherzoro,实际上,这是一个不同的错误,因为我们解决了第一个问题,您应该为此创建一个新问题,并且包含失败的SQL通常需要提供援助 – 2014-10-17 13:22:56

+0

好吧,我认为它有帮助,但没有相同的错误看起来:http://pastebin.com/R1f77QiF和我不在乎,如果它将注射我的网站将是私人没有人会知道。 – 2014-10-17 13:24:17

0

您的错误发生在SQL查询where声明中。

你的代码是:

string checkuser = "select count(*) from SystemMemberInfo where Username="+ TextBoxUserName.Text +"'"; 

要纠正它,把它写这种方式:

string checkuser = "select count(*) from SystemMemberInfo where Username='" + TextBoxUserName.Text + "'"; 
+0

http://pastebin.com/iDCEwp9U – 2014-10-17 13:13:36