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!

Error says Parameter not included?

Status
Not open for further replies.

Amesville

Programmer
Oct 10, 2011
93
US
Hi Folks

Working on a VB 2008 app with SQL Server Express 2008 R2 back end. I have the following code I'm using to call a stored proc in SQL Server that takes one parameter, @Par1, which is a character value. The Value of Param1 (being passed in at the top of the function is "HO" (could be any two-letter combination).

When I try to run this the call seems to be finding the SP just fine, but it tells me that "Procedure or function '<proc Name>' expects parameter '@Par1', which was not supplied." You can see plainly below that it is, in fact, being sent.

Code:
    Public Function FillDtSp1(ByVal ProcName As String, ByVal Param1 As String) As DataTable

        Dim dcLk As New SqlCommand(ProcName, cnHTT)
        Dim daFillDt As New SqlDataAdapter(dcLk)

        daFillDt.SelectCommand.Parameters.Add("@Par1", SqlDbType.Char, (40)).Value = Param1
        Dim dt1 As New DataTable

        If cnHTT.State <> ConnectionState.Open Then cnHTT.Open()
        daFillDt.Fill(dt1)
        If cnHTT.State <> ConnectionState.Closed Then cnHTT.Close()

        Return dt1

    End Function

I've tried this as both an added parameter on the SQLCommand object and on the SQLDataAdapter, results are the same. Any ide why this might be happening to me?

Craig

Amesville
 
Think I answered my question for myself - I added a property call to the Command opject setting it as a stored procedure instead of Text and that seems to have fixed it.
 
FYI, you'll want to post your VB.Net database questions in the VB.Net forum. This forum got its name before there was a VB.Net, was intended for VB5 and VB6 database issues, and isn't seeing a lot of traffic these days.

An unforeseen consequence of the information revolution has been the exponential propagation of human error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top