System.Data.OleDb.OleDbException (0x80040E14):查询表达式"Email='12"和密码"12"中的语法错误(缺少运算符)



它已经连接到数据库,但当我试图从数据库中读取以验证登录时,我会收到这个错误。

System.Data.OleDb.OleDbException (0x80040E14): Syntax error (missing operator) in query expression 'Email= '12' and Password 'fgrt''.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
at COSSA_E_Voting_System.LoggingIn.guna2Button2_Click(Object sender, EventArgs e) in C:UserskusicDesktopCOSSA E-Voting SystemLoggingIn.cs:line 72
at System.Windows.Forms.Control.OnClick(EventArgs e)
at Guna.UI2.WinForms.Guna2Button.OnClick(EventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


这是点击按钮登录时的代码

con.Open();
OleDbCommand cmd = new OleDbCommand();
OleDbDataAdapter da = new OleDbDataAdapter();
// cmd.Connection = con;
string login = "SELECT * FROM tbl_students WHERE Email= '" + txtEmail.Text + "' and Password '" + txtPassword.Text + "'";
cmd = new OleDbCommand(login, con);

OleDbDataReader reader;
reader = cmd.ExecuteReader();

if (reader.Read() == true)
{

MessageBox.Show("Email and Password is valid!");
}

这看起来像是一个位大小错误。尝试将您的项目从ANY cpu更改(强制(为x86,然后重新构建——看看这是否有效。

相关内容

  • 没有找到相关文章

最新更新