Advertisement

11.07.2007 at 08:25AM PST, ID: 22944993
[x]
Attachment Details

Conversion from string to type Double is not valid in vb.net 2005

Asked by ljhodgett in Visual Studio .NET 2005, .NET

Tags: string

Hi,

I have the following code: -

    Private Sub lstOrderRequirements_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstOrderRequirements.SelectedIndexChanged
        'If Not lstOrderRequirements.SelectedValue.ToString Is Nothing Then
        If Not lstOrderRequirements.SelectedValue Is Nothing Then
            Connect()
            rs = conn.Execute("SELECT * FROM products where ItemID =" & lstOrderRequirements.SelectedValue.ToString)

            txtCustomer.Text = ""
            txtBayNo.Text = ""
            txtItemName.Text = ""
            txtItemCode.Text = ""
            txtCostPerItem.Text = ""
            txtBoxesPerItem.Text = ""
            'MsgBox(rs.Fields("CustomerID").Value)

            If Not rs.Fields("CustomerID").Value Is DBNull.Value Then txtCustomer.Text = "" = rs.Fields("CustomerID").Value
            If Not rs.Fields("BayID").Value Is DBNull.Value Then txtBayNo.Text = "" = rs.Fields("BayID").Value
            If Not rs.Fields("ItemName").Value Is DBNull.Value Then txtItemName.Text = "" = rs.Fields("ItemName").Value
            If Not rs.Fields("ItemCode").Value Is DBNull.Value Then txtItemCode.Text = "" = rs.Fields("ItemCode").Value
            If Not rs.Fields("Cost").Value Is DBNull.Value Then txtCostPerItem.Text = "" = rs.Fields("Cost").Value
            If Not rs.Fields("Boxes").Value Is DBNull.Value Then txtBoxesPerItem.Text = "" = rs.Fields("Boxes").Value
            rs.Close()
            conn.Close()
        End If

    End Sub

I keep getting the error message: -

Conversion from string "" to type 'Double' is not valid. on line: -

If Not rs.Fields("CustomerID").Value Is DBNull.Value Then txtCustomer.Text = "" = rs.Fields("CustomerID").Value

How do I resolve this please.

Many Thanks
LeeStart Free Trial
[+][-]11.07.2007 at 08:31AM PST, ID: 20233606

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.07.2007 at 08:33AM PST, ID: 20233626

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Visual Studio .NET 2005, .NET
Tags: string
Sign Up Now!
Solution Provided By: jaime_olivares
Participating Experts: 2
Solution Grade: A
 
 
[+][-]11.07.2007 at 10:57AM PST, ID: 20235078

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628