Hi,
I just want to know if my information are correct:
the reader with the sql or.. database can always access the reader.read() method but if there is no data found it retrieves 0 or null as result,
but with the access database if there is no data then the reader.read() is false and does not access the content written in reader.read()
which means in sql when I put
reader.read(){
//write a code
}
the reader accesses the code but retrieves null result if no data found but with the access database the reader does not even access the code if no data found right?
Loading

VulpesRank #55 · 29.2K reputationPosted Sep 19, 2012, 2:08 AM EDT
It follows that you can only access the record if the Reader() method returns true.
abed akhi71 reputationPosted Sep 19, 2012, 2:15 AM EDT
VulpesRank #55 · 29.2K reputationPosted Sep 19, 2012, 4:50 AM EDT
I think you may be confusing the situation with similar functions in other languages (such as C) which typically return 0 if there are no more records.
In C#, there are no conversions defined between the int and bool types even though bools are represented by single bytes with values of 0 (for false) or 1 (for true).
abed akhi71 reputationPosted Sep 19, 2012, 8:36 AM EDT
sqlcommand s=new sqlcommand("Select id from table where username=etc");
while (reader.read())
{
id=Int32.Parse(reader[0].tostring());
}
I had an id=0 althought there wasn't any username that is called etc...
so it entered the .read() method even if it's false..
Or am I missing something here?
VulpesRank #55 · 29.2K reputationPosted Sep 19, 2012, 9:06 AM EDT
If that's an Id column, then I don't know how the existence of such a record could come about without knowing the structure of the database and the query used to build the record-set.
abed akhi71 reputationPosted Sep 20, 2012, 1:13 AM EDT
int id=0;
and then the while (reader.read()){id=Int32.parse(reader[0].tostring)} and then if id!=0 do something, :) I think that because I did it since too long my ideas are jumbled thanks again you're right.