Active Server Pages Programming (ASP)/datareader
Expert: Srini Nagarajan - 4/4/2005
Question connecttodb()
query="select count(fieldname) from tbladinfo where subcategoryid= '" & item & "' "
executequery()
executereader()
if datareader.read=true
response.write(item)
' while datareader.read()
*response.write(datareader"(count(fieldname)"))
' end while
end if
datareader.close()
closecon()
how read value of query through datareader
as it gaves indexoutofrange error in this context
AnswerHi
Sorry for the delay in reply!
Use Do while loop
Here is the sample script
mCommand.Execute(out mReader);
// Use Read to read data line by line.
while (mReader.Read())
{
// YOUR script here
Response.Write(mReader.GetString(0) + ":" + mReader.GetInt32(1));
}
// Close the Reader when done.
mReader.Close();
// Close the connection when done.
mConnection.Close();
Happy Programming!
Srini