I have a stored procedure ( SQL Server 2005 )set ANSI_NULLS ONset QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[usp_GetLotAttributes] @AttrNum int = NULL, @LotID varchar(11) = NULLASSELECT * FROM Fab5IE_LastTables.dbo.tblLastTablesWHERE RecordIsOpen = 1 AND (LastAttr = ISNULL(@AttrNum,LastAttr) AND LotNum = ISNULL(@LotID,LotNum))ORDER BY LastAttr
I'm writting code in MSExcel to extract informationusing the following code!The function to run the stored procedure is Function Fab5IE_GetDataStoredProc(strItem As String, strParamString As String, tgtForData As Variant) As Boolean' Local Variables Dim adoConn As New ADODB.Connection Dim adoRst As New ADODB.Recordset Dim adoPrm As ADODB.Parameter Dim adoCmd As command Dim strDBConn As String Fab5IE_GetDataStoredProc = False On Error GoTo L___ExitEarly' Open a connection strDBConn = strFab5IE adoConn.Open strDBConn' Set query Set adoCmd = New ADODB.command With adoCmd .ActiveConnection = adoConn .CommandText = strItem .CommandType = adCmdStoredProc End With Set adoPrm = adoCmd.CreateParameter("@AttrNum", adInteger, adParamInput) adoCmd.Parameters.Append adoPrm Set adoPrm = adoCmd.CreateParameter("@LotNum", adVarChar, adParamInput, 11) adoCmd.Parameters.Append adoPrm adoCmd.Parameters("@AttrNum") = CInt(Split(strParamString, ",")(0)) adoCmd.Parameters("@LotNum") = Split(strParamString, ",")(1)' Loop the incomming device list and ret template info Set adoRst = adoCmd.Execute' Disconnect the Recordset Set adoRst.ActiveConnection = Nothing' Return the Recordset Set tgtForData = adoRst' Clean up... adoConn.Close' adoRst.Close Set adoConn = Nothing Set adoRst = Nothing Exit FunctionL___ExitEarly: Fab5IE_GetDataStoredProc = FalseEnd Function
The call to the function is this Call Fab5IE_GetDataStoredProc("usp_GetLotAttributes", "102,1J5199", adoRst)
I keep getting a recordset that has a record count of 1... 1. I need to know how to use the execute the stored procedure with null values2. Can on a given stored procedure can I get a parameter list returned?