|
-
Pulling @variables from a SQL query/sproc into vb/vba vairable
Been struggling with this for a few hours now.
I have a SQL query which gives three vairables (however I can get it to push these vairables out in a 'Select @StatusOn, @StatusOff, @StatusTest' at the end. (this is stored as strSQL)
My code is as follows then I will go through what I have tried
*******************************************************
Dim cnn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim prm As New ADODB.Parameter
With cnn
.Open "DRIVER={SQL Server};SERVER=MYSERVER;DATABASE=MYDB;"
End With
With cmd
.ActiveConnection = cnn
.CommandTimeout = 0
.CommandType = adCmdText
.CommandText = strSQL
End With
cmd.Execute
Set prm = cmd.CreateParameter("StatusOn", adDate, adParamOutput, , **@SatausOn**)
cmd.Parameters.Append prm
Set prm = cmd.CreateParameter("StatusOff", adDate, adParamOutput, , **@StatusOff**)
cmd.Parameters.Append prm
Set prm = cmd.CreateParameter("StatusTest", adDate, adParamOutput, , **@StatusTest**)
cmd.Parameters.Append prm
Set cnn = Nothing
*******************************************************
I have pushed the SQL and got it to dump it out then ran it manually and the SQL is bringing back values
I have tested the the parameters are being created and appended to the cmd howver I cant get the prm to be filled with the output value of the query. 
I dont know what to put in **@StatusOn**
I could get the query to return a single record at a time, however this sits within a loop and dont want to hit the DB 3 times per loop
The query can either put out records as variables or in a single row with 3 fields.
I am at a loss with this, I know it has to be possible
Any help would be fantastic
Similar Threads
-
By zicq in forum Database
Replies: 2
Last Post: 05-18-2003, 10:16 PM
-
By Dan Staggs in forum Careers
Replies: 0
Last Post: 08-07-2002, 11:04 AM
-
Replies: 1
Last Post: 06-07-2002, 11:12 AM
-
By Aaron Coombs in forum ASP.NET
Replies: 2
Last Post: 09-26-2001, 03:29 AM
-
By myLittleTools.net in forum web.announcements
Replies: 0
Last Post: 03-10-2001, 12:35 PM
Tags for this Thread
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks