Hi,
I cant seem to get this working right...I have a datareader which i loop through...i want to test each value to see if its null but i cant get the syntax right.
I know i use dr.item("columnname") or dr(0) to pick a certain column but i dont know the column names and want to check them all anyway. What is the syntax to do this.
Thanks for any help...this is prob very simple but just cant see it.
--------------
While dr.ReadIf dr(0)Is System.DBNull.ValueThen
Return"test"
EndIfEndWhile
I useually would add the following to identify the columns by:
msgbox(dr(0))
msgbox(dr(2)) and so on.
or use response.write(dr(0))
|||
Hi
Ireland,
Ireland:
...i want to test each value to see if its null but i cant get the syntax right.
if i remember right, no VS in front of me, its similar to
while(reader.Read()){// not sure if fields the correct property namefor(int i=0; i < reader.fields.count; i++) {// iterate throu all fields in the rowif(reader[i] ==typeof(string)) {string str = reader[i]; } }}
the correct property you see in the reader intellisence. But i think it was fields
|||
you can try dr.FieldCount. That will give you the number of columns in the datareader.
The code will be something like this (sorry my VB.NET is no good)
While dr.Read
for iCtr=0 to dr.FieldCount
if dr(iCtr) Is System.DBNull.Value Then
Return "test"
End If
Next
End While