我在這裏20行錯誤是錯誤行:連接字符串INT ASP錯誤
int temp = Convert.ToInt32(com.ExecuteScalar().ToString());
頁面我的代碼:Pastebin
頁錯誤顯示:Pastebin
我在這裏20行錯誤是錯誤行:連接字符串INT ASP錯誤
int temp = Convert.ToInt32(com.ExecuteScalar().ToString());
頁面我的代碼:Pastebin
頁錯誤顯示:Pastebin
錯誤說:
字符stri之後未封閉的引號ng''。
你的SQL命令是:
string checkuser = "select count(*)
from SystemMemberInfo
where Username="+ TextBoxUserName.Text +"'";
如果你看一下你的字符串,你會發現,你在你的WHERE子句的末尾有一個引號,而不是在開頭。
你的WHERE子句應該更像:
where Username='"+ TextBoxUserName.Text +"'";
這樣也請不要做查詢,他們很容易受到SQL Injection attacks。
Nope http://pastebin.com/iDCEwp9U – 2014-10-17 13:16:06
@herobrinebrotherzoro,實際上,這是一個不同的錯誤,因爲我們解決了第一個問題,您應該爲此創建一個新問題,並且包含失敗的SQL通常需要提供援助 – 2014-10-17 13:22:56
好吧,我認爲它有幫助,但沒有相同的錯誤看起來:http://pastebin.com/R1f77QiF和我不在乎,如果它將注射我的網站將是私人沒有人會知道。 – 2014-10-17 13:24:17
您的錯誤發生在SQL查詢where
聲明中。
你的代碼是:
string checkuser = "select count(*) from SystemMemberInfo where Username="+ TextBoxUserName.Text +"'";
要糾正它,把它寫這種方式:
string checkuser = "select count(*) from SystemMemberInfo where Username='" + TextBoxUserName.Text + "'";
http://pastebin.com/iDCEwp9U – 2014-10-17 13:13:36
什麼是com.ExecuteScalar()的'值的ToString()'和你有什麼'CurrentCulture'?請在此處將您的代碼和錯誤消息顯示爲文本。由於我現在在工作,因此pastebin域被防火牆阻止。 – 2014-10-17 13:00:27
它告訴你到底發生了什麼錯誤:'在字符串''之後未使用引號' – Jonesopolis 2014-10-17 13:02:22
嘗試解決您的選擇,如下所示:'從SystemMemberInfo中選擇count(*),其中Username ='「+ TextBoxUserName.Text +」'「 ;' – 2014-10-17 13:02:31