B
Bob
Hi,
i need the most recent date but only for a certain category:
'dat' is DateTime type in sql server.
dim dat as datetime
sql = "select max(dat) from mytable where cat='x'
comd = New SqlCommand(sql, mConnection)
dat = comd.ExecuteScalar
If there are no cat= 'x', comd.executescaler returns Null and so i get the
error:
"Conversion from type 'DBNull' to type 'Date' is not valid."
I tried this: If Not IsDBNull(0) Then dat = comd.ExecuteScalar
or with .HasRows ...
but it doesn't work.
Thanks for help
Bob
i need the most recent date but only for a certain category:
'dat' is DateTime type in sql server.
dim dat as datetime
sql = "select max(dat) from mytable where cat='x'
comd = New SqlCommand(sql, mConnection)
dat = comd.ExecuteScalar
If there are no cat= 'x', comd.executescaler returns Null and so i get the
error:
"Conversion from type 'DBNull' to type 'Date' is not valid."
I tried this: If Not IsDBNull(0) Then dat = comd.ExecuteScalar
or with .HasRows ...
but it doesn't work.
Thanks for help
Bob