Weird problem with accessing accessdb

Y

yossimotro

OleDbConnection con;
OleDbCommand cmd;
OleDbDataReader reader;

con = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
Server.MapPath("App_Data\\db.mdb") + ";");
con.Open();

cmd = new OleDbCommand("Select tblUsers.userID from tblUsers
WHERE tblUsers.Login = ? AND tblUsers.Password = ?", con);

cmd.Parameters.Add("Login", txtUser.Text.ToString());
cmd.Parameters.Add("Password", txtPass.Text.ToString());


reader = cmd.ExecuteReader();
---------------------------------------------------------

After this is executed I get the following error:

No value given for one or more required parameters.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: No value given for
one or more required parameters.

Source Error:


Line 42:
Line 43:
Line 44: reader = cmd.ExecuteReader();
Line 45:
Line 46:

What could be the cause of it?


Yossi.
 
G

Guest

Yossi,
There is nothing wrong with your code. That means either there is / are no
values for "txtUser.Text.ToString());" etc., or that the names of the
parameters are incorrect.

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top