Hi
How can i check if some value exists in the data reader
How can i do that ? any ideas please .

>How can i check if some value exists in the data reader
How can i do that ?

IF dataReader.Read() Then
    IF IsDBNull(dataReader("col1")) Then
    ...
    ELSE
    ....
    END IF
End If

Thank you, But i don't mean that
I have a dates in the DR column1
And i want to check if :

If DateTime.Now = 'Any value in the column1
IF dataReader.Read() Then
    If Not IsDBNull(dataReader("dateColumn")) Then
        Dim dateTest As DateTime
        ' Test to see if the value in the database is a date
        If DateTime.TryParse(dataReader("dateColumn"), dateTest) Then
            If dateTest = DateTime.Now Then
                ' Do something
            End If
        End If
    END IF
End If

It does not work :'(
The column1 in datareader is a datetime in the DB
So maybe i don't need to check if its date or not.

Read post #2 and #4 - dataReader.Read() method returns true if value exists, return false otherwise.

I am not checking if value exist
I want to check about a certain value (DateTime.Now)
dr.read only check if any value exist

That is true.
However, before you can safely check the value, you need to check if the value exist.
Errors have been known to occur from time to time when storing to a database.
Therefore, first check if value exists. Then check if the value happens to be NULL.
After that, you can do your thing.

This is the part you're asking for.
In order to compare two dates, first make sure they are of the same type. Hence the call to DateTime.TryParse() method.

Dim dateTest As DateTime
        ' Test to see if the value in the database is a date
        If DateTime.TryParse(dataReader("dateColumn"), dateTest) Then
            If dateTest = DateTime.Now Then
                ' Do something
            End If
        End If
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.