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:
CREATE PROCEDURE [dbo].[sp_GetPhoneInfoByName] @ClientName VARCHAR(50) AS BEGIN SET NOCOUNT ON; SELECT ClientInformation.ClientInfoID_PK, ClientInformation.ClientName, ClientInformation_PhoneNumbers.ClientPhoneNumber, ClientInformation_PhoneNumbers.ClientInfoID_PKFK, ClientInformation_PhoneNumbers.PhoneNumberTypeID_PKFK, ClientInformation_PhoneNumberType.PhoneNumberTypeID_PK, ClientInformation_PhoneNumberType.PhoneNumberTypeName FROM ClientInformation INNER JOIN ClientInformation_PhoneNumbers ON ClientInformation.ClientInfoID_PK = ClientInformation_PhoneNumbers.ClientInfoID_PKFK INNER JOIN ClientInformation_PhoneNumberType ON ClientInformation_PhoneNumberType.PhoneNumberTypeID_PK = ClientInformation_PhoneNumbers.PhoneNumberTypeID_PKFK WHERE ClientInformation.ClientName = @ClientName END
The stored procedure created without issue. In my code, I have the following:
vb Code:
'Set the attributes for the SQLCommand. With MySQLCommand .Connection = SetDatabaseConnection .CommandType = CommandType.StoredProcedure .CommandText = "sp_GetPhoneInfoByName" .Parameters.AddWithValue("@ClientName", "'" & cboClientName.Text.Trim.ToString & "'") 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.




Reply With Quote