Thread: cast problem
View Single Post
 
Old September 6th, 2004, 03:55 AM
vickyj vickyj is offline
Authorized User
 
Join Date: Sep 2004
Location: Delhi, Delhi, India.
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default cast problem

I write following code

dim chk as string
Dim maxid as integer

cmdmax = New SqlCommand("select max(Reply_ID) from Reply where Q_ID='" & Request("Topic") & "' and Tech_ID='" & Request("Tech") & "' ", conPubs)

        chk = cmdmax.ExecuteScalar
        If (chk = "NULL") Then
            maxid = 0
        Else
            maxid = CInt("chk")
        End If
        maxid = maxid + 1

It gives the following error
"Cast from type 'DBNull' to type 'String' is not valid."
What is the problem.

vicky
__________________
vicky