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
VulpesPosted Sep 19, 2012, 6:08 AM
It follows that you can only access the record if the Reader() method returns true.
abed akhiPosted Sep 20, 2012, 5:13 AM
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.
VulpesPosted Sep 19, 2012, 1:06 PM
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 akhiPosted Sep 19, 2012, 12:36 PM
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?
VulpesPosted Sep 19, 2012, 8:50 AM
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 akhiPosted Sep 19, 2012, 6:15 AM