小编Wra*_*der的帖子

System.Data.SqlClient.SqlException: '''' 附近的语法不正确。

我正在尝试使用 ASP.NET 创建一个登录字段,它将从文本框字段中获取输入并根据我的数据库中的“用户”表检查它们。列是User IDPassword。但是一个错误

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)

c# sql-server asp.net-mvc visual-studio

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

asp.net-mvc ×1

c# ×1

sql-server ×1

visual-studio ×1