P
Paul W
Trying to run a stored proc in excel via ADO. My code returns no
errors on this, but I get no data back in my recordset. Running the
code manually on SQL or via MS Query with the same parameters returns
data. Can anyone see or think of something that I might be missing?
Dim cn As ADODB.Connection
Dim cmd As ADODB.Command
Dim rst As ADODB.Recordset
Dim intRowIndex As Integer
Dim intDataIndex As Integer
Set cn = New ADODB.Connection
cn.Open "Driver={SQL
Server};Server=MyServer;Trusted_Connection=yes;Database=MyDb"
Set cmd = New ADODB.Command
cmd.ActiveConnection = cn
cmd.CommandText = "SOGoodChannel"
cmd.CommandType = adCmdStoredProc
cmd.Parameters.Refresh
cmd.Parameters(1).Value = strRunType
cmd.Parameters(2).Value = CInt(frmDates.cbxMonth.Text)
cmd.Parameters(3).Value = CInt(frmDates.cbxYear.Text)
Set rst = cmd.Execute
--
CREATE PROCEDURE dbo.SOGoodChannel @strType Char(1),
@intMonth Integer,
@intYear Integer
AS
BEGIN
IF @strType = 'I'
BEGIN
Run Query 1
END
ELSE
BEGIN
IF @strType = 'C'
BEGIN
Run Query 2
END
ELSE
BEGIN
Run Query 3
END
END
END
GO
Thanks,
Paul W
errors on this, but I get no data back in my recordset. Running the
code manually on SQL or via MS Query with the same parameters returns
data. Can anyone see or think of something that I might be missing?
Dim cn As ADODB.Connection
Dim cmd As ADODB.Command
Dim rst As ADODB.Recordset
Dim intRowIndex As Integer
Dim intDataIndex As Integer
Set cn = New ADODB.Connection
cn.Open "Driver={SQL
Server};Server=MyServer;Trusted_Connection=yes;Database=MyDb"
Set cmd = New ADODB.Command
cmd.ActiveConnection = cn
cmd.CommandText = "SOGoodChannel"
cmd.CommandType = adCmdStoredProc
cmd.Parameters.Refresh
cmd.Parameters(1).Value = strRunType
cmd.Parameters(2).Value = CInt(frmDates.cbxMonth.Text)
cmd.Parameters(3).Value = CInt(frmDates.cbxYear.Text)
Set rst = cmd.Execute
--
CREATE PROCEDURE dbo.SOGoodChannel @strType Char(1),
@intMonth Integer,
@intYear Integer
AS
BEGIN
IF @strType = 'I'
BEGIN
Run Query 1
END
ELSE
BEGIN
IF @strType = 'C'
BEGIN
Run Query 2
END
ELSE
BEGIN
Run Query 3
END
END
END
GO
Thanks,
Paul W