المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : OleDbDataReader error



C# Programming
11-05-2009, 04:52 AM
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data source= C:/data.accdb;User Id=admin;Password=";
string sql = "SELECT UserName, UserPassword FROM TblUsers";
OleDbCommand cmd = new OleDbCommand(sql, conn);
OleDbDataReader dbReader = cmd.ExecuteReader();

dbReader = cmd.ExecuteReader();

while (dbReader.Read())
{
UserName = dbReader.GetString(3).ToString();
PassWord = dbReader.GetString(4).ToString();
}

dbReader.Close();
conn.Close();

i have an error in the Data Reader. the error lies in,OleDbDataReader dbReader = cmd.ExecuteReader(); adn it say it has no value given for one or more parameters. I have ask my friends and they say the problem is the,string sql = "SELECT UserName, UserPassword FROM TblUsers";

so now i know that the problem lies in the string sql.
but i do not know what to change in the string.

can anyone help?? :S
i will really appreciate it! thank you.