View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Parameters.Refresh

Jim,

I don't think that is what you want.

I don't have a database on this machine, so I cannot test it, but I think
you want code along these lines

Dim cnn As ADODB.Connection
Dim cmd As ADODB.Command
Dim parm1 As ADODB.Parameter
Dim parm2 As ADODB.Parameter
Dim rs As ADODB.Recordset

Set cnn = New ADODB.Connection
Set cmd = New ADODB.Command
cnn.ConnectionString = "Provider=MSDAORA.1;" & _
"Password=YYYYYY;" & _
"UserID=XXXXX;" & _
"Data Source=ZZZZZZZ;" & _
"Persist Security Info=True"
cnn.Open cnn.ConnectionString
With cmd
.CommandText = "mySP"
.CommandType = adCmdStoredProc
.ActiveConnection = cnn.ConnectionString
End With

Set parm1 = cmd.CreateParameter( _
Name:="i_User_ID", _
Type:=adInteger, _
Direction:=adParamInput, _
Value:=1)
Set parm2 = cmd.CreateParameter( _
Name:="i_Time_ID", _
Type:=adInteger, _
Direction:=adParamInput, _
Value:=136)

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

Set rs = cmd.Execute


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Jim Heavey" wrote in message
...
I was looking for documentation as to what the Parameters.Refresh method
does. I suspect that it is somehow initializing the Parameter oject

within
the Command with the number of parameters which are in my stored

procedure.

Anyway, when I get to that line of code I get a "-2147217900 (80040e14)"

and
that message says, more or less that my SQL statement is invalid. The

only
SQL statement I have is what is calling the stored procedure. In the

message
box I seem to be getting message back from Oracle indicating that I have

the
wrong number of paramters and/or the wrong types. At this juncture, I

have
not loaded my parameters.

Here is my code....

Dim cnn As New ADODB.Connection
Dim Rs As ADODB.Recordset
cnn.ConnectionString = "Provider=MSDAORA.1;Password=YYYYYYYY;User
ID=XXXXXX;Data Source=ZZZZZZZZZZ;Persist Security Info=True"
cnn.Open

Dim cmd As New ADODB.Command
cmd.ActiveConnection = cnn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "OPS_UI_QUERIES.QRY_PROD_Data"
cmd.Parameters.Refresh

cmd.Parameters(1).Name = "i_User_ID"
cmd.Parameters(1).Type = adInteger
cmd.Parameters(1).Value = 1
cmd.Parameters(2).Name = "i_Time_ID"
cmd.Parameters(2).Type = adInteger
cmd.Parameters(2).Value = 136

Set Rs = cmd.Execute

Any ideas as to what is wrong?

Thanks in advance for your assistance.