Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Calling stored proc with parameters ..


Hi,

How to call a stored proc with parameters from Excel VBA? Withou
parameters, it goes something like -

.................................................. ......
Set Comm = New ADODB.Command
Comm.ActiveConnection = Conn
With Comm
.CommandText = <STORED PROC NAME
.CommandType = adCmdStoredProc
.Execute
End With
.................................................. ......

But I am not able to call SP with multiple parameters. Can someon
help please.

Thanks in advance,

Harish Mohanbab

--
Harish Mohanba

-----------------------------------------------------------------------
Harish Mohanbab's Profile: http://www.excelforum.com/member.php...nfo&userid=633
View this thread: http://www.excelforum.com/showthread.php?threadid=46818

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Calling stored proc with parameters ..

You need to create a parameter object and append it. See below for an
example. For each parameter you need on parameter object. Look at the ADO
examples code for further details.



dim myParameter as adodb.parameter

set myParameter = new adodb.parameter


with myParameter
.name ="whatever the parameter name is"
.type = whatever type
end with




Comm.parameters.append myParameter


--
www.alignment-systems.com


"Harish Mohanbab" wrote:


Hi,

How to call a stored proc with parameters from Excel VBA? Without
parameters, it goes something like -

.................................................. ......
Set Comm = New ADODB.Command
Comm.ActiveConnection = Conn
With Comm
.CommandText = <STORED PROC NAME
.CommandType = adCmdStoredProc
.Execute
End With
.................................................. ......

But I am not able to call SP with multiple parameters. Can someone
help please.

Thanks in advance,

Harish Mohanbabu


--
Harish Mohanbab


------------------------------------------------------------------------
Harish Mohanbab's Profile: http://www.excelforum.com/member.php...fo&userid=6332
View this thread: http://www.excelforum.com/showthread...hreadid=468186


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Calling stored proc with parameters ..

Hi John,

Thanks to your pointer, I finished that code last week itself :-) I had to
tweak the code slightly though. Have posted the same below. Hopefully some
one some day finds this useful -
______________________________________________
......................
......................
Set Comm = New ADODB.Command
Comm.CommandText = <Name of Stored Proc
Comm.CommandType = adCmdStoredProc

Set paramSO = Comm.CreateParameter("SO", adWChar, adParamInput, 8,
txtField.Value)
Comm.Parameters.Append paramSO
Comm.ActiveConnection = Conn
Comm.Execute
......................
......................
______________________________________________

Thanks,

Harish Mohanbabu
MBS Axapta - MVP
http://www.harishm.com/

"John.Greenan" wrote:

You need to create a parameter object and append it. See below for an
example. For each parameter you need on parameter object. Look at the ADO
examples code for further details.



dim myParameter as adodb.parameter

set myParameter = new adodb.parameter


with myParameter
.name ="whatever the parameter name is"
.type = whatever type
end with




Comm.parameters.append myParameter


--
www.alignment-systems.com

Reply
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
return multiple results from stored proc [email protected] Excel Programming 1 June 15th 05 11:27 AM
execte stored proc maxzsim Excel Programming 1 May 10th 05 05:50 PM
calling a stored access query from excel vba Travis Excel Programming 1 April 25th 05 09:11 PM
External Data from Stored Procedure with parameters Ben Rum Excel Programming 2 April 12th 05 04:23 PM
Stored Procedure call and passing parameters TLowe Excel Programming 3 April 23rd 04 10:09 AM


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

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

About Us

"It's about Microsoft Excel"