Excel Execute a Stored Procedure, How to... :: MrExcel Message Board


 FAQFAQ
   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   StatisticsStatistics 
 RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Online StoreOnline Store

MrExcel Message Board Forum Index -> Excel Questions

Execute a Stored Procedure, How to...
Post new topic   Reply to topic
Last Thread | Next Thread  >   Printable version
  Author    Thread

Ed S.
Board Regular


Joined: 27 Mar 2002
Posts: 75


Status: Offline

 Reply with quote  

Trying to execute a stored procudure in VBA.
(Excel 97).

following is out of a textbook, but does not work - should be pretty close.

Does not recognize method on dim statments.

Set Con1 = New ADODB.Connection
Dim Cmd1 As New ADODB.Command
Con1.Open "DSN=BD01;UID=PASSWORD;PWD=xxxx;"
Cmd1.CommandText = "{CALL QGPL.MYPROCTEST (?)}"
Cmd1.Execute
JobNum = Cmd1.Parameters(0).Value
Set Cmd1 = Nothing
Con1.Close
Set Con1 = Nothing

End Sub

Does Excel 97 suppport ADO technology

If can be done via sql, that's fine.

_________________
EMSS

Post Tue Jan 14, 2003 5:03 pm 
 View user's profile Send private message Send e-mail

dk
MrExcel MVP


Joined: 16 Feb 2002
Posts: 1910

Flag: Blank

Status: Offline

 Reply with quote  

You need to set the appropriate reference. From the VB editor choose Tools, References and tick Microsoft ActiveX Data Object 2.n Library where n depends on what version you have installed.

Post Wed Jan 15, 2003 1:42 am 
 View user's profile Send private message

Ed S.
Board Regular


Joined: 27 Mar 2002
Posts: 75


Status: Offline

 Reply with quote  

DK - thank you.

Q. how do i find/determine the ADO level installed?

Here is the finished code for the next person - works like magic...

Sub Connection()

Dim Con1 As New ADODB.Connection
Dim Cmd1 As New ADODB.Command
Con1.Open "DSN=MyDSN;UID=MYID;PWD=MyPWD;"
Cmd1.ActiveConnection = Con1
Cmd1.CommandText = "{CALL QGPL.MYPROCTEST (?)}"
Cmd1.Parameters.Refresh
Cmd1.Execute
JobNum = Cmd1.Parameters(0).Value
Set Cmd1 = Nothing
Con1.Close
Set Con1 = Nothing

End Sub

_________________
EMSS

Post Wed Jan 15, 2003 1:48 pm 
 View user's profile Send private message Send e-mail

dk
MrExcel MVP


Joined: 16 Feb 2002
Posts: 1910

Flag: Blank

Status: Offline

 Reply with quote  


quote:

On 2003-01-15 08:48, Ed S. wrote:
DK - thank you.

Q. how do i find/determine the ADO level installed?



You should see several versions of ADO installed. For example, my machine looks has versions 2.0, 2.1 and 2.5. To determine the most recently installed run this small piece of code:-

code:

Sub GetADOVersion()
Set Conn = CreateObject("ADODB.CONNECTION")
MsgBox "You are using version " & Conn.Version & " of the MS ADO Library"
End Sub



Post Wed Jan 15, 2003 9:32 pm 
 View user's profile Send private message
  Display posts from previous:      

MrExcel Message Board Forum Index -> Excel Questions


Forum Jump:
Jump to:  

Post new topic   Reply to topic
Page 1 of 1



Add To Favorites

 


Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB: 2.0.4 © 2001 phpBB Group

Need help posting your first question? Read how to post

Need extra help ? Couldn't get the answer you needed ? Get a free quote from our Consulting Team

Download Colo's HTML Maker utility for displaying your Excel Worksheet on the board.

Download VB HTML Maker to post your code on the board


Check out our new index to 485 Excel Articles.


Return to MrExcel Consulting

All contents Copyright 1998-2004 by MrExcel.com
If you believe information posted here is from your copyrighted source, notify us per the Terms of Use
Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.