Error with cmdQuestion.ExecuteReader(out dr);

P

Patrick.O.Ige

I have a code PASTED below.Its validate(login) against a database SQL
SERVER.
But i have a problem with the LINE:- "cmdQuestion.ExecuteReader(out dr);"
below

its says ERROR :-

"The best overloaded method match for
'System.Data.SqlClient.SqlCommand.ExecuteReader(System.Data.CommandBehavior)
' has some invalid arguments"

Can anybody help?

-------------------------------------------------------------
// Create a command to get the question

SqlCommand cmdQuestion = new SqlCommand("SELECT Password FROM Users WHERE
Email = '" + Email.Text + "'", cn);

// Create a datareader to get the question


//myCommand.ExecuteReader();

cmdQuestion.ExecuteReader(out dr);



// Get the first row

if(dr.Read())
if(dr["Password"].ToString() == Password.Text)
CookieAuthentication.RedirectFromLoginPage(Email.Text, false);
else
Msg.Text = "Invalid password.";
else
Msg.Text = "Email address not found.";
}
}
 
D

David Coe, MCP

Patrick

The ExecuteReader method only has two signatures -- one with no parameters, and one with a CommandBehavior parameter. If you are trying to compare the passwords, then you can also do something like

SqlDataReader reader = cmdQuestion.ExecuteReader()

while(reader.Reader()

if(reader["Password"] == Password.Text
// do something vali
els
// do something invali
}
 

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

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top