0

This is the error when i try to execute my code "Procedure or function 'Get Customer data' expects parameter '@Name', which was not supplied."

objCommand.CommandType = CommandType.StoredProcedure
        objCommand.CommandText = "GetCustomerData"
        Dim ObjParam1 As New SqlParameter("@Name", SqlDbType.VarChar, 2000)

        ObjParam1.Value = ID.ToString()

        Dim da As New SqlDataAdapter(objCommand)
        Dim dt As New DataTable
        da.Fill(dt)// error shows here
        DetailsView2.DataSource() = dt
        DetailsView2.DataBind()

        objConnection.Close()

In debugging, i c the value in ObjParam1.value that I'm passing.
Any suggestions please.

Thanks

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by crapulency
0

You are creating the SqlParameter Object but you're not adding it to the Command Object.

Sorry I don't have the time to look it up... but there should be some sort of method of the objCommand to add parameters to it.

something like
objCommand.Parameter.Add("@Name", SqlDbType.Int, 4)
objCommand.Parameters["@Name"].Value = ID.ToString

Edited by the_carpenter: typo

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.