Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
|
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 30th, 2005, 04:48 PM
h3x h3x is offline
Registered User
 
Join Date: Jan 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Cast from string "" to type 'Integer' is not valid

hi there i just started .NET (ASP n VB) this semester n i created this webpage which brings back data from the database ... whn i enter the search parameter it gives me this error .. "Cast from string "" to type 'Integer' is not valid."
heres my code ...plz help me out ...

LookUpInventoryByStockNumber.aspx.vb

Private Sub btnSearchInvt_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearchInvt.Click

        Try
            Dim InventoryInformation As DataSet = Lab1.OrderSystem.LookUpInventoryByStockNumber(txtE mpID2.Text, StockNum.Text)
            If InventoryInformation.Tables("InventoryInformation" ).Rows.Count > 0 Then
                With InventoryInformation.Tables("InventoryInformation" ).Rows(0)
                    StockNum.Text = .Item("StockNumber")
                    InventoryNumber.Text = .Item("InventoryNumber")
                    Description.Text = .Item("Description")
                    Price.Text = .Item("Price")
                    ReOrderLevel.Text = .Item("ReOrderLevel")
                    UnitCost.Text = .Item("UnitCost")
                    OrderUnitSize.Text = .Item("OrderUnitSize")
                    OrderUnitType.Text = .Item("OrderUnitType")
                    Discontinued.Text = .Item("Discontinued")
                    QuantityOnHand.Text = .Item("QuantityOnHand")
                End With
            Else
                lblErrStock.Text = txtEmpID2.Text & " was not found "
            End If
        Catch ex As Exception
            lblErrStock.Text = ex.Message
        End Try
    End Sub

Inventory.vb
Public Class Inventory
    Public Shared Function LookInventoryByStockNumber(ByVal EmployeeID As Integer, ByVal StockNum As Integer) As DataSet
        Dim eVideo As SqlConnection = New SqlConnection(eVideoConnectionString)
        Dim adapter As SqlDataAdapter = New SqlDataAdapter("exec LookUpInventoryByStockNumber @EmployeeID, @StockNum", eVideo)
        adapter.SelectCommand.Parameters.Add("@EmployeeID" , SqlDbType.Int).Value = EmployeeID
        Dim InventoryInformation As DataSet = New DataSet
        adapter.Fill(InventoryInformation, "InventoryInformation")
        Return InventoryInformation
    End Function
End Class


 
Old January 30th, 2005, 09:35 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

Check your data types and make your they are consistent in your statements.

Jaime E. Maccou





Similar Threads
Thread Thread Starter Forum Replies Last Post
Cast from string to type Double not valid mika27 ASP.NET 2.0 Basics 0 January 31st, 2007 05:52 AM
Err: Cast from String "" to type byte is not valid Parbish BOOK: Beginning VB.NET Databases 1 July 9th, 2005 05:43 PM
Cast from string "" to type 'Double' is not dounme SQL Server 2000 1 February 18th, 2005 01:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.