Cast from string 'OPEN' to type 'Double' is not valid.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Cast from string 'OPEN' to type 'Double' is not valid.

  1. #1
    Join Date
    Aug 2007
    Posts
    30

    Cast from string 'OPEN' to type 'Double' is not valid.

    Hi.. Please help me resolve this error "Cast from string 'OPEN' to type 'Double' is not valid.". Error here
    Code:
    If CallStatus = 10
    Then ....
    Code:
    Code:
    Public Sub UpdateCallStatus()
            Dim CALLID, RequestorID, CommentsFromITD, MessageFromITD, MessageToITD, CallStatus, strSQL As String
            CALLID = Request.QueryString("CallID")
            RequestorID = Session("USER_ID")
            CommentsFromITD = lblcomments.Text
            MessageFromITD = lblmessage.Text
            MessageToITD = txt_desc.Text
            CallStatus = Trim(Request.Form(ddl_callstatus.UniqueID))
    
            Dim ObjCmd As SqlCommand
            Dim ObjDR As SqlDataReader
    
            Try
                If CallStatus = 10 Then
                    strSQL = "UPDATE CALLS  SET STATUS_ID=" & CallStatus & " WHERE CALL_ID=  " & CALLID & ""
                    ObjCmd = New SqlCommand(strSQL, ObjConn)
                    ObjConn.Open()
                    ObjDR = ObjCmd.ExecuteScalar()
                    gbVariables.insertuserevents(CALLID, RequestorID, "Call Closed")
                    Response.Redirect("UserCallClosed.aspx")
                    ObjConn.Close()
                Else
                    strSQL = "UPDATE CALLS  SET STATUS_ID=" & CallStatus & " WHERE CALL_ID=  " & CALLID & ""
                    ObjCmd = New SqlCommand(strSQL, ObjConn)
                    ObjConn.Open()
                    ObjDR = ObjCmd.ExecuteScalar()
                    ObjConn.Close()
    
                    strSQL = "SELECT STATUS_LABEL  FROM STATUS WHERE STATUS_ID = " & CallStatus & ""
                    ObjCmd = New SqlCommand(strSQL, ObjConn)
                    ObjConn.Open()
                    ObjDR = ObjCmd.ExecuteScalar()
                    ObjConn.Close()
    
                    gbVariables.insertuserevents(CALLID, RequestorID, CallStatus)
                    CallStatus = ""
                End If
            Catch ex As Exception
                lblmsg.Text = ex.Message.ToString
            End Try
        End Sub
    Thanks...

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    You declare CallStatus as a String on this line:

    Dim CALLID, RequestorID, CommentsFromITD, MessageFromITD, MessageToITD, CallStatus, strSQL As String

    Then you compare it with a numeric value here:

    If CallStatus = 10 Then

    What is the value of CallStatus? The error message seems to indicate that it has a value of "OPEN", but your code looks like you expect it to be a number.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Mar 2005
    Location
    Los Angeles, Calif. AKA: Gangsta Yoda™
    Posts
    455
    Also if CallStatusis a string variable and your database field data type is a string then you need to wrap the compared variable with single quotes if its a string. Otherwise you need to be using an Integer data type and change your code evaluations appropriately.

    If string value...
    ...SET STATUS_ID='" & CallStatus & "' WHERE
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer code questions via PMs.
    Microsoft MVP 2006-2009
    Office Development FAQ (VBA, VB6, VB.NET, C#)
    Software Engineer MCP (VB6 & .NET)
    Reps & Rating PostsVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6Outlook Global Address List

Similar Threads

  1. Submitting Infopath to a .net Web Service
    By athomas42 in forum .NET
    Replies: 1
    Last Post: 06-25-2007, 04:54 PM
  2. Input string was not in a correct format
    By mdengler in forum ASP.NET
    Replies: 0
    Last Post: 11-26-2002, 02:32 PM
  3. Writing in HKEY_LOCAL_MACHINE...Access is denied
    By Martin in forum VB Classic
    Replies: 22
    Last Post: 12-03-2001, 03:53 AM
  4. Please help me -- urgent -- deadlock error
    By chandra in forum VB Classic
    Replies: 0
    Last Post: 06-22-2000, 07:36 AM
  5. Database problems
    By Robert Rieth in forum VB Classic
    Replies: 1
    Last Post: 04-11-2000, 03:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center