I have a stored procedure:
I'm calling this from a VB6 program.
If in the stored procedure I specify default values for the parameters then when I call the it I get all the expected records returned. If I try to pass the values to the parameters from my program then a recordset is returned (I'm using it to populate a DataGrid and I get the field names in the column headers) but it is empty.
What am I missing here? Any assistance will be greatly appreciated...
Brad
Code:
CREATE PROCEDURE [spGroupProduction]
@StartDate smalldatetime, @EndDate smalldatetime
AS
SELECT Metrix.TRANSID, Metrix.EMPID, Metrix.[Date],
Metrix.Account, Metrix.Category, Metrix.TransType,
Metrix.Time, Metrix.Department, Metrix.Unit, Metrix.InputDate,
Standard.Standard
FROM Metrix LEFT JOIN
Standard ON Metrix.Category = Standard.Category
WHERE
Metrix.[Date] BETWEEN @StartDate AND @EndDate
Code:
Dim cn As ADODB.Connection
Dim Cmd As ADODB.Command
Dim rs As ADODB.Recordset
Dim dtStartDate As Date
Dim dtEndDate As Date
dtStartDate = DTPicker1.Value
dtEndDate = DTPicker2.Value
strConnection = "Provider=SQLOLEDB.1;" & _
"Integrated Security=SSPI;" & _
"Persist Security Info=False;" & _
"Initial Catalog=ToolsBars;" & _
"Data Source=bocasql1"
Set cn = New ADODB.Connection
cn.ConnectionString = strConnection
cn.CursorLocation = adUseClient
cn.Open
Set rs = New ADODB.Recordset
Set Cmd = New ADODB.Command
With Cmd
.ActiveConnection = cn
.CommandType = adCmdStoredProc
.CommandText = "spGroupProduction"
.Parameters.Refresh
.Parameters(1).Value = dtStartDate
.Parameters(2).Value = dtEndDate
Set rs = .Execute()
End With
Set DataGrid1.DataSource = rs
Set Cmd = Nothing
Set cn = Nothing
What am I missing here? Any assistance will be greatly appreciated...
Brad