本文介绍了获取System.Data.OleDb.OleDbException(0x80040E14):查询表达式Exception中的语法错误(缺少运算符)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在C#ASP .Net中设计了一个登录页面.我正在使用Oledbcommand来检查登录凭据.

以下是代码:-

试试

I have designed a login page in C# ASP .Net.I am using Oledbcommand to check the login credential.

Following is the code:-

try

{
                string connect = "Provider=Microsoft.Jet.OleDb.4.0; Data Source=C:/Users/jahart/Documents/Visual Studio 2010/Projects/ScindiaEvents/ScindiaEvents/Account/Events.mdb;";
                string query = "Select Count(*) From Students Where User ID = ? And Psswrd = ?";
                int result = 0;
                using (OleDbConnection conn = new OleDbConnection(connect))
                {
                    using (OleDbCommand cmd = new OleDbCommand(query, conn))
                    {
                        cmd.Parameters.AddWithValue("User ID", "TextBox1.Text");
                        cmd.Parameters.AddWithValue("Psswrd", "TextBox2.Text");
                        conn.Open();
                        Session["User"] = TextBox1.Text;
                        result = (int)cmd.ExecuteScalar();
                    }
                }
                if (result > 0)
                {
                    Response.Redirect("Default.aspx");
                }
                else
                {
                    lblMessage.Text = "Invalid credentials";
                }

            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.ToString();
            }
        }


当我单击登录"按钮时,出现异常,即[System.Data.OleDb.OleDbException(0x80040E14):查询表达式用户ID =?"中的语法错误(缺少运算符)和Psswrd =?''在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.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteScalar() at ScindiaEvents.Account.Login.Button1_Click(Object sender, EventArgs e) in C:\Users\jahart\Documents\Visual Studio 2010\Projects\ScindiaEvents\ScindiaEvents\Account\Login.aspx.cs:line 47]

有人可以在这方面帮助我吗?

预先感谢.


When I Click on Login button I get an exception i.e. [System.Data.OleDb.OleDbException (0x80040E14): Syntax error (missing operator) in query expression ''User ID = ? And Psswrd = ?''. 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.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteScalar() at ScindiaEvents.Account.Login.Button1_Click(Object sender, EventArgs e) in C:\Users\jahart\Documents\Visual Studio 2010\Projects\ScindiaEvents\ScindiaEvents\Account\Login.aspx.cs:line 47]

Can somebody pls help me on this part.

Thanx in advance.

推荐答案


这篇关于获取System.Data.OleDb.OleDbException(0x80040E14):查询表达式Exception中的语法错误(缺少运算符)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 18:40