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: 119
Default execute stored proc in Excel

Hi,
i'm trying to execute a stored proc stored in Sybase in VBA EXCEL 2003. the
stored proc is supposed to return about 30 rows. but, if i execute the stored
proc in VBA, rs.recordcount is -1 and rs.eof is true. i enclosed the stored
proc below. it just makes me very frustrated. any help or feedback is very
welcome.
Thank you very much.
will

MsgBox rs.RecordCount == ALWAYS RETURN -1

While Not rs.EOF == rs.EOF = TRUE


create procedure sp_CoverageEventHorizonHistory
@NoteDBSecId varchar(30)
as



select s.Symbol, s.SecurityName as 'Company', t.PriceTarget_Numeric
from Securities s, TargetPriceActions t
where s.NoteDBSecId =@NoteDBSecId
and s.NoteDBSecId=t.NoteDBSecId and t.PriceTarget_Numeric !=NULL


go





Private Sub CommandButton1_Click()

Dim DB As BSERDBConnect.BSERDataConnect
Dim con As ADODB.Connection
Dim comm As ADODB.Command
Dim rs As ADODB.Recordset

Dim SQL As String

Set DB = New BSERDataConnect
DB.connectDB "database", "login", "pwd"


Set conn = DB.oConn
Set comm = New ADODB.Command
Set rs = New ADODB.Recordset

comm.ActiveConnection = conn
comm.CommandType = adCmdStoredProc
comm.CommandText = "sp_CoverageEventHorizonHistory"


Dim paramIn1 As ADODB.Parameter

Set paramIn1 = comm.CreateParameter("NoteDBSecId", adVarChar,
adParamInput, 30, "1782")
comm.Parameters.Append paramIn1

Dim records As Integer

rs.CursorLocation = adUseClient
Set rs = comm.Execute(records)

Set wksEH = Worksheets("TESTING")

For c = 0 To rs.Fields.Count - 1
wksEH.Cells(1, c + 1).Value = rs.Fields(c).Name
Next
With wksEH.Rows(1).Cells.Font
.Underline = True
.Bold = True
End With

MsgBox rs.RecordCount == ALWAYS RETURN -1
Do While Not rs Is Nothing
While Not rs.EOF == rs.EOF = TRUE
MsgBox rs.Fields(0) & " " & rs.Fields(1)
rs.MoveNext
Wend
Set rs = rs.NextRecordset
Loop

Set comm = Nothing

End Sub



--

 
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
DAO recordset Call to SQL Stored Proc Datasort Excel Programming 0 December 1st 05 06:06 PM
Calling stored proc with parameters .. Harish Mohanbab[_3_] Excel Programming 2 September 19th 05 03:58 PM
return multiple results from stored proc [email protected] Excel Programming 1 June 15th 05 11:27 AM
execute stored procedure from excel maxzsim Excel Worksheet Functions 3 May 11th 05 04:58 PM
execte stored proc maxzsim Excel Programming 1 May 10th 05 05:50 PM


All times are GMT +1. The time now is 01:17 PM.

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"