[英]System.Data.OleDb.OleDbException (0x80040E14): Syntax error (missing operator) in query expression 'Email= '12' and Password '12''
it has connected to the database, but when I try to read from the database to validate login, I get this error.它已连接到数据库,但是当我尝试从数据库中读取以验证登录时,出现此错误。
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:\Users\kusic\Desktop\COSSA E-Voting System\LoggingIn.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)
This is the code when the button login is clicked这是单击按钮登录时的代码
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!");
}
this looks like a bit size error.这看起来像位大小错误。 Try changing (force) your project from ANY cpu to x86, and re-build - see if that works.尝试将您的项目从 ANY cpu 更改(强制)为 x86,然后重新构建 - 看看是否可行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.