本文介绍了消息='Userdata'附近的语法不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString);
conn.Open();
string checkUser = " select count(*) form Userdata where Username='" + TextBoxUN.Text + "' ";
SqlCommand cmd = new SqlCommand(checkUser,conn);
***获得异常---
*** getting exception ---
System.Data.SqlClient.SqlException was unhandled by user code
HResult=-2146232060
Message=Incorrect syntax near 'Userdata'
此行
at this line
int temp= Convert.ToInt32(cmd.ExecuteScalar().ToString()); // ***
if (temp==1)
{
Response.Write("User Already Exists");
}
conn.Close();
推荐答案
string checkUser = " select count(*) form Userdata where Username='" + TextBoxUN.Text + "' ";
应该是:
Should be:
string checkUser = " select count(*) FROM Userdata where Username='" + TextBoxUN.Text + "' ";
这篇关于消息='Userdata'附近的语法不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!