Compare DBNull

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have a table with two fields
brand_code Text(2) PK
brand_name Varchar(20)

Brand_code is generated automatically. If no records are there in the table
the new brand_code will be "01"

else right("00" & max(brand_code)+1,2)

select max(convert(integer,brand_code)) from brands

How can i read the value? I tried with Sqldatareader
dr=cmd.executereader()

How can i know whether it has retrieved any rows or not.
If i run this query from SQLQueryAnalyzer it returns a row with NULL coz no
records initially.
How can i read that value?
 
' Visual Basic .NET
If (dr.HasRows) Then
dr.Read()
If (dr.IsNull(0)) Then
Console.WriteLine ("NULL")
Else
Console.WriteLine (dr.GetValue(0))
End If
End If
dr.Close()

Hope this helps.

Hello,

I have a table with two fields
brand_code Text(2) PK
brand_name Varchar(20)

Brand_code is generated automatically. If no records are there in the table
the new brand_code will be "01"

else right("00" & max(brand_code)+1,2)

select max(convert(integer,brand_code)) from brands

How can i read the value? I tried with Sqldatareader
dr=cmd.executereader()

How can i know whether it has retrieved any rows or not.
If i run this query from SQLQueryAnalyzer it returns a row with NULL coz no
records initially.
How can i read that value?
 
Back
Top