我正在尝试使用 ASP.NET 创建一个登录字段,它将从文本框字段中获取输入并根据我的数据库中的“用户”表检查它们。列是User ID和Password。但是一个错误
System.Data.SqlClient.SqlException: ''' 附近的语法不正确
使用登录表单时出现。我没有看到任何语法问题...
我是新手,所以如果错误很明显,请原谅!
public partial class Login_Page : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lblErrorMessage.Visible = false;
SqlConnection con = new SqlConnection("Data Source=JACKS-PC\\SQLEXPRESS;Initial Catalog=CBR;Integrated Security=True");
con.Open();
}
protected void btnLogin_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=JACKS-PC\\SQLEXPRESS;Initial Catalog=CBR;Integrated Security=True";
con.Open();
string userid = txtUsername.Text.Trim();
string password = txtPassword.Text.Trim();
SqlCommand cmd = new SqlCommand("select `user id`,`password` from user where `user id`='" + …Run Code Online (Sandbox Code Playgroud)