954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Procedure or function 'Get Customer data' expects parameter

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

uzn
Newbie Poster
8 posts since Oct 2010
Reputation Points: 10
Solved Threads: 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

the_carpenter
Junior Poster in Training
65 posts since Aug 2010
Reputation Points: 32
Solved Threads: 11
 

hi uzn. Try inserting this line:

objCommand.Parameters.Add(objParam1)
crapulency
Junior Poster in Training
53 posts since Jun 2010
Reputation Points: 10
Solved Threads: 18
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: