Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expects Parameter not supplied

Status
Not open for further replies.

tsp1lrk72

IS-IT--Management
Feb 25, 2008
100
US
This is driving me nuts... I can't seem to figure out what is wrong with this, I keep getting: Prepared statement '(@VendorID int)Select VI.VendorID, VI.DivisionName, VI.DeptName,' expects parameter @VendorID, which was not supplied. "

Code:
 Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Define connection to read the data 
        Dim myConn As New SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
        Dim MyCmd As New SqlCommand("Select VI.VendorID, VI.DivisionName, VI.DeptName, VI.VendorCode, VI.VendorName, VI.Responsibility, VI.Joined, VI.SKU, VI.EDI, VI.RBT, VI.ContactName, VI.ContactPhone, VI.ContactFax, VI.EmailAddress, VS.Status From tblVendorInfo VI Join tblVendorComments VM On VI.VendorID = VM.VendorID Join tblVendorStatus VS On VI.CurrentStatus = VS.StatusID Where VendorID = @VendorID", myConn)
        MyCmd.CommandType = CommandType.Text
        MyCmd.Parameters.Add(New SqlParameter("@VendorID", SqlDbType.Int, 4)).Value = Convert.ToString(VendorID)
        myConn.Open()
        'Read the data
        Dim Result As SqlDataReader = MyCmd.ExecuteReader(CommandBehavior.CloseConnection)
        Result.Read()
        VendorNumber.Text = Result("VendorID").ToString()
        If Not Result.IsDBNull(0) Then
            DivisionName.Text = Result("DivisonName").ToString()
        End If
        If Not Result.IsDBNull(0) Then
            DeptName.Text = Result("DeptName").ToString()
        End If
        If Not Result.IsDBNull(0) Then
            VendorName.Text = Result("VendorName").ToString()
        End If
        If Not Result.IsDBNull(0) Then
            Joined.Text = Result("Joined").ToString()
        End If
        If Not Result.IsDBNull(0) Then
            SKU.Text = Result("SKU").ToString()
        End If
        If Not Result.IsDBNull(0) Then
            EDI.Text = Result("EDI").ToString()
        End If
        If Not Result.IsDBNull(0) Then
            Rbt.Text = Result("RBT").ToString()
        End If
        If Not Result.IsDBNull(0) Then
            ContactName.Text = Result("ContactName").ToString()
        End If
        If Not Result.IsDBNull(0) Then
            ContactPhone.Text = Result("ContactPhone").ToString()
        End If
        If Not Result.IsDBNull(0) Then
            ContactFax.Text = Result("ContactFax").ToString()
        End If
        If Not Result.IsDBNull(0) Then
            EmailAddress.Text = Result("EmailAddress").ToString()
        End If
        If Not Result.IsDBNull(0) Then
            Comment.Text = Result("Comment").ToString()
        End If
        myConn.Close()
    End Sub

Any ideas???
Thanks
 
I think this is question to VB.NET forum, not for SQL Server one. I am not sure but PARAMETERS should be identified as ? in the query string:
Code:
Where VendorID = ?myVendorID
...
 MyCmd.Parameters.Add(New SqlParameter("myVendorID", SqlDbType.Int, 4)).Value = VendorID
But you better check this.

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
Microsoft MVP VFP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top