LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Need help with ADO in Excel

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;Dat abase=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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"