2012年2月19日星期日

Fujitsu call to sproc via ADO using a parameter

I am trying to call a stored proc using a parameter via ADO exceute,
but cannot get the syntac correct.
Any help is much appreciated.
thanks,If your stored procedures doesn't have any output parameter then you can use the execute method of connection object as given below

Conn.Execute "Usp_GetEmp 1, '01/01/2002'"

assuming the sp has two input parameters, integer datatype as first parameter and date as second parameter.

If your stored procedure have output parameters then you have to use the command object of the ADO Object Library.

I hope this helps you

:)|||If you need to have a resultset returned from the stored procedure you would have to use the command object as well. If you need to use the command object, please post the stored procedure parameters.|||Getting a returned result set via exec is OK.

The problem is with trying to figure out how to set up the parameters array in order to pass the parameters!

e.g. how would I run something like the [Sales by Year] from Northwind, which requires 2 parameters? (let's say we ignore the ouput)|||Try the following:

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim cmd As ADODB.Command

Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
Set cmd = New ADODB.Command

cn.Open "Your Connection String"
With cmd
Set .ActiveConnection = cn
.CommandText = "[Sales by Year]"
.CommandType = adCmdStoredProc
.Parameters.Append .CreateParameter("Beginning_Date", _
adDate, adParamInput)
.Parameters("Beginning_Date").Value = "1/1/1980"
.Parameters.Append .CreateParameter("Ending_Date", _
adDate, adParamInput)
.Parameters("Ending_Date").Value = "1/1/2000"
End With
rs.Open cmd

' close/destroy the connection, command, recordset objects

rs.Close
Set rs = Nothing
Set cmd = Nothing
cn.Close
Set cn = Nothing|||Thanks.

Unfortunately I'm looking for Fujitsu COBOL syntax , but I do appreciate your help.|||Do you have a help file on how to use ado with fujitsu cobol ? If so, please post and I will check it out.|||Ahhh. If I had that I wouldn't have had to have posted!! Fujitsu's support refers one to MSDN where one finds solutions such as yours.

They don't have any documentation re ADOor any examples of how to use it, although their marketing material states specifically that they support it.

Which is why I posted here in the first place.

Thanks again.|||You mean to say there is no online help for the ado syntax. What about an object reference - not necessarily a help document. Do you have connection, command and recordset objects ? If all else fails, you could create a com object in vb and reference that in your cobol colde.|||To say that the documentation is sparse is an understatement. Also what's there is incomplete and/or misleading in some cases, so it's not of much use.

We could create a component in VB, well Delphi probably, as that's our preferred development platform, but we specifically bought Fujitsu due to its claimed support for ADO. (To be honest, the compiler probably does support ADO, but the documentation isn't saying how, especially in the realm of parameter passing ...

没有评论:

发表评论