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

مشاهدة النسخة كاملة : Exception in C#



C# Programming
10-03-2009, 10:31 PM
HI,
Im gettin an exception saying "InvalidOperationException" nd it says "No data exists for the row/coloumn", for the following code, nd d exception results on the d line that has been underlined....please check d code nd help....plssss!!!!

int rnd;
int totalcount = 0;
Random SelectRandom = new Random();
OleDbConnection access = new OleDbConnection();
OleDbCommand accesscmd = new OleDbCommand();
OleDbDataReader reader;
if (combo_Category.Text == "Book")
{
string connectionstring = "Provider = Microsoft.Jet.OLEDB.4.0;
Data Source = |DataDirectory|\\HangmanDatabase.mdb";
access.ConnectionString = connectionstring;
access.Open();
accesscmd.CommandText = "Select * From Book";
accesscmd.Connection = access;
reader = accesscmd.ExecuteReader();
while (reader.Read())
{
totalcount = totalcount + 1;
}
if (reader.HasRows)
{
rnd = SelectRandom.Next(0,totalcount - 1);
book = reader[0].ToString();
datastring = book.ToCharArray();
}
access.Close();
convert();
}

Pleassssssss help!!!

?:::...£!???...:::?