用户代码 sql 异常未处理的 ASP.NET SQL 连接

问题描述

我一直在学习使用 ASP.NET MVC 的教程,并在完成后 我可以很好地运行我的登录表单,但是当我输入我的用户名和密码并单击提交时,它给了我一个错误 sqlException is unhandled by user code in here

“System.Data.sqlClient.sqlException”类型的异常发生在 System.Data.dll 但未在用户代码中处理 附加 信息:'ad' 附近的语法不正确。

void connectionString()
{
    con.ConnectionString = "data source=DESKTOP-94CAMNQ; database=LibrarySystemDB; Integrated Security = sspI;";
}

[HttpPost]
public ActionResult Verify(Account acc)
{
    connectionString();
    con.open();
    com.Connection = con;
    com.CommandText = "Select*From tbl_login where Username='"+acc.Username+"'and Password'"+acc.Password+"'";
    dr = com.ExecuteReader();
    if (dr.Read())
    {
        con.Close();
        return View("Create");
    }
    else
    {
        con.Close();
        return View("Error");
    }              
}
 

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)