|
-
Jan 17th, 2001, 11:24 AM
#1
Thread Starter
Member
How do you call a Stored Procedure from a SQL 7.0 Database from Visual Basic?
-
Jan 17th, 2001, 11:33 AM
#2
Lively Member
Code:
dim moADODB as new ADODB.Connection
dim mrsData as new ADODB.Recordset
moADODB.Open msconnection
mrsData.Open "exec sp_Collect " & lsParams, moADODB.Connection, adOpenStatic
would do the trick
Anakim
It's a small world but I wouldn't like to paint it.
-
Jan 17th, 2001, 11:37 AM
#3
PowerPoster
AngelaMicikas, hope this can help you.
Code:
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim cmd As ADODB.Command
Set conn = New ADODB.Connection
conn.Open "Provider=SQLOLEDB;Data Source=Chris;Database=pubs;User Id=sa;password=;"
Set cmd = New ADODB.Command
cmd.CommandText = "<Your Store Procedure Name>"
cmd.CommandType = adCmdStoredProc
Set cmd.ActiveConnection = conn
Set rs = cmd.Execute
With rs
'Do what ever you want here
End With
Set cmd = Nothing
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
-
Jan 17th, 2001, 11:39 AM
#4
Addicted Member
This should do it...
Dim objConn as ADODB.Connection
Dim objCmd as ADODB.Command
Dim objRs as ADODB.Recordset
<Set and open connection object>
Set objCmd = New ADODB.Command
objCmd.CommandType = adCmdStoredProc
objCmd.CommandText = " <StoredProcName>"
objCmd.ActiveConnection = objConn
Set objRs = objCmd.Execute
If the Stored Procedure does not return a recordset, then the last line would be:
objCmd.execute lRecReturned
Where lRecReturned = number of records affected by executing the Stored Procedure...
Building A Better Body Albeit Left Out Under Intense Extrapolation
-
Jan 17th, 2001, 12:01 PM
#5
Thread Starter
Member
THANKS ALL!! BIG HELP, HUGE!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|