0

i have the following code which works fine where there is data in the table.

when the table is empty and there is no data in the @Ctotal varible i get my error

MessageBox.Show("Unable to get Claim Total")


is there anyway i can ignore this if there isn't a value in the @ctotal?

Private Sub Gettotal()
        Dim con As New SqlConnection
        Dim cmd As New SqlCommand
        Try
            con.ConnectionString = "Data Source=" & ServerV & ";Initial Catalog=" & databaseV & ";Persist Security Info=True;User ID=" & usernameV & ";Password=" & passwordV & ""
            con.Open()
            cmd.Connection = con
            cmd.CommandText = "ClaimTotal"
            cmd.CommandType = CommandType.StoredProcedure

            Dim number1Param As New SqlParameter("@Ctotal", SqlDbType.Money, 4)
            number1Param.Direction = ParameterDirection.Output
            cmd.Parameters.Add(number1Param)

            Dim reader As SqlDataReader = cmd.ExecuteReader()

            Me.lbtotal.Text = Convert.ToDouble(number1Param.Value)
        Catch ex As Exception

            MessageBox.Show("Unable to get Claim Total")
        Finally
            con.Close()
        End Try

    End Sub
4
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by Unhnd_Exception
Featured Replies
0

i do not know if i am right, i normally add an isnull into a query, but i beleive in .net it is

if string.isnullorempty 
do what if it is nothing
else
do what if it is something
end if

that could be wrong though.

1
if number1param.value is dbnull.value then
  lbltotal.text = "0"
else
  lbltotal.text = cdbl(number1param.value).tostring
endif
Votes + Comments
thanks, i wasnt positive
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.