Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Stored Procedures - First Attempt

I am trying to figure out how to call a stored procedure. I have entered the
following lines of code ....

Dim cmd As New Command
cmd.CommandType = adCmdStoredProc
Dim parm1 As Parameter
With parm1
.DataType = xlParamTypeInteger
.Name = "i_User_ID"
.Value = 1
End With
Dim parm2 As Parameter
With parm2
.Name = "i_Time_ID"
.DataType = xlParamTypeInteger
.Value = 136
End With
cmd.Parameters.Append (parm1)
cmd.Parameters.Append (parm2)
cnn.ConnectionString = "Provider=MSDAORA.1;Password=YYYYYY;User
ID=XXXXX;Data Source=ZZZZZZZ;Persist Security Info=True"
cmd.ActiveConnection = cnn
cmd.Execute

The code fails when I attempt to place something into my Parameter with the
following error "Object Variable or with block not set". Sounds like it
wants me to instatiate the object, but I can not use the "new" with
"Parameter" object.

So what am I doing wrong? How do I associate the Command Object with the
Connection Object....I was guessing "cmd.ActiveConnection".

Thanks in advance for your assistance!!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Stored Procedures - First Attempt

This doesn't look like Excel to me.

Maybe you wanted to post in one of the Access newsgroups.

Jim Heavey wrote:

I am trying to figure out how to call a stored procedure. I have entered the
following lines of code ....

Dim cmd As New Command
cmd.CommandType = adCmdStoredProc
Dim parm1 As Parameter
With parm1
.DataType = xlParamTypeInteger
.Name = "i_User_ID"
.Value = 1
End With
Dim parm2 As Parameter
With parm2
.Name = "i_Time_ID"
.DataType = xlParamTypeInteger
.Value = 136
End With
cmd.Parameters.Append (parm1)
cmd.Parameters.Append (parm2)
cnn.ConnectionString = "Provider=MSDAORA.1;Password=YYYYYY;User
ID=XXXXX;Data Source=ZZZZZZZ;Persist Security Info=True"
cmd.ActiveConnection = cnn
cmd.Execute

The code fails when I attempt to place something into my Parameter with the
following error "Object Variable or with block not set". Sounds like it
wants me to instatiate the object, but I can not use the "new" with
"Parameter" object.

So what am I doing wrong? How do I associate the Command Object with the
Connection Object....I was guessing "cmd.ActiveConnection".

Thanks in advance for your assistance!!!


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Stored Procedures - First Attempt

These objects are all available in VBA within Excel. Not sure why you are
suggesting that this is not Excel related....it is.

I have figured out that I need to specify ADODB.Parameter and this gets me
by the error that I was experiencing, but then it fails which I attempt to
load the parameters into the Command Object.

I get the error "object required" for the following commands

cmd.Parameters.Append (parm1)
cmd.Parameters.Append (parm2)

The code to create parm1, looks like the following:

Dim parm1 As New ADODB.Parameter
With parm1
.Type = adInteger
.Name = "i_User_ID"
.Value = 1
End With

When I hover over parm1, is see the value of "1" being displayed back to me.
Why does the cmd.Parameters.Append (parm1) fail?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Stored Procedures - First Attempt

Did you declare the command as adodb?

Dim cmd As New ADODB.Command


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Jim Heavey" wrote in message
...
These objects are all available in VBA within Excel. Not sure why you are
suggesting that this is not Excel related....it is.

I have figured out that I need to specify ADODB.Parameter and this gets me
by the error that I was experiencing, but then it fails which I attempt to
load the parameters into the Command Object.

I get the error "object required" for the following commands

cmd.Parameters.Append (parm1)
cmd.Parameters.Append (parm2)

The code to create parm1, looks like the following:

Dim parm1 As New ADODB.Parameter
With parm1
.Type = adInteger
.Name = "i_User_ID"
.Value = 1
End With

When I hover over parm1, is see the value of "1" being displayed back to

me.
Why does the cmd.Parameters.Append (parm1) fail?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Stored Procedures - First Attempt

I think, at the very least, you should be using ADO data types, not Excel.

So

.DataType = xlParamTypeInteger

should be

.DataType = adInteger

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Jim Heavey" wrote in message
...
I am trying to figure out how to call a stored procedure. I have entered

the
following lines of code ....

Dim cmd As New Command
cmd.CommandType = adCmdStoredProc
Dim parm1 As Parameter
With parm1
.DataType = xlParamTypeInteger
.Name = "i_User_ID"
.Value = 1
End With
Dim parm2 As Parameter
With parm2
.Name = "i_Time_ID"
.DataType = xlParamTypeInteger
.Value = 136
End With
cmd.Parameters.Append (parm1)
cmd.Parameters.Append (parm2)
cnn.ConnectionString = "Provider=MSDAORA.1;Password=YYYYYY;User
ID=XXXXX;Data Source=ZZZZZZZ;Persist Security Info=True"
cmd.ActiveConnection = cnn
cmd.Execute

The code fails when I attempt to place something into my Parameter with

the
following error "Object Variable or with block not set". Sounds like it
wants me to instatiate the object, but I can not use the "new" with
"Parameter" object.

So what am I doing wrong? How do I associate the Command Object with the
Connection Object....I was guessing "cmd.ActiveConnection".

Thanks in advance for your assistance!!!





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
Pivotcharts and stored procedures omar_aa Charts and Charting in Excel 5 October 9th 08 02:35 AM
Can I import SQL Stored Procedures into Excel? Nick Gill Excel Discussion (Misc queries) 0 September 11th 08 11:42 AM
How to connect Excel to stored procedures in SQL database? tskogstrom Excel Discussion (Misc queries) 1 July 3rd 07 09:40 AM
Running sql stored procedures from Excel in-over-his-head-bill Excel Discussion (Misc queries) 0 July 5th 06 06:30 PM
Can Access stored procedures be executed from within Excel rmcompute Excel Programming 0 November 19th 05 10:14 PM


All times are GMT +1. The time now is 02:47 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"