Results 1 to 11 of 11

Thread: [RESOLVED] Procedure or function expects parameter which was not supplied.

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Resolved [RESOLVED] Procedure or function expects parameter which was not supplied.

    Hi all,

    I was working on this thread in regard to DataRelations on multiple tables. If I use CommandType = CommandType.Text, the code does as expected. However, I decided to take the SQL query and throw it into a stored proc. I then changed my code to use the stored procedure and I get the error as per the title of this thread.

    The stored procedure is as follows:
    vb Code:
    1. CREATE PROCEDURE [dbo].[sp_GetPhoneInfoByName]
    2. @ClientName VARCHAR(50)
    3. AS
    4. BEGIN
    5. SET NOCOUNT ON;
    6.  
    7. SELECT ClientInformation.ClientInfoID_PK,
    8.        ClientInformation.ClientName,
    9.        ClientInformation_PhoneNumbers.ClientPhoneNumber,
    10.        ClientInformation_PhoneNumbers.ClientInfoID_PKFK,
    11.        ClientInformation_PhoneNumbers.PhoneNumberTypeID_PKFK,
    12.        ClientInformation_PhoneNumberType.PhoneNumberTypeID_PK,
    13.        ClientInformation_PhoneNumberType.PhoneNumberTypeName
    14. FROM ClientInformation
    15. INNER JOIN ClientInformation_PhoneNumbers
    16. ON ClientInformation.ClientInfoID_PK = ClientInformation_PhoneNumbers.ClientInfoID_PKFK
    17. INNER JOIN ClientInformation_PhoneNumberType
    18. ON ClientInformation_PhoneNumberType.PhoneNumberTypeID_PK = ClientInformation_PhoneNumbers.PhoneNumberTypeID_PKFK
    19. WHERE ClientInformation.ClientName = @ClientName
    20. END

    The stored procedure created without issue. In my code, I have the following:
    vb Code:
    1. 'Set the attributes for the SQLCommand.
    2.                         With MySQLCommand
    3.                             .Connection = SetDatabaseConnection
    4.                             .CommandType = CommandType.StoredProcedure
    5.                             .CommandText = "sp_GetPhoneInfoByName"
    6.                             .Parameters.AddWithValue("@ClientName", "'" & cboClientName.Text.Trim.ToString & "'")
    7.                         End With

    When I use the SQL Profiler, I see that NULL is being passed to the stored procedure. I have looked online and haven't been able to find an answer. Anyone here have any ideas? Thanks.
    Attached Images Attached Images  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width