Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Call a stored function with ADO

Status
Not open for further replies.

FBELGHAIT

Programmer
Mar 22, 2002
10
0
0
US
Hi,

I have a stored function created in a postgres database, that function returns an integer value and i want to run that function from VB using ADO.

I used

with vcmd
.CommandType = adCmdStoredProc
.CommandText = "fn_insertdata" 'fn_insertdata is the
name of the function
.Parameters.Append .CreateParameter
("@v_time_change", adInteger, adParamInput)
.execute
end with

vb freeses at this point, and some time windows close the application.
if some one know how to call a stored function with ado and how to retreive the obtain value into a variable. it would be very helpful

fbelghait
 
'Assuming you have a valid connection object 'cn', your ado
'command object needs a few more properties identified:

Set cmd = New ADODB.Command
Set cmd.ActiveConnection = cn

cmd.CommandText = "sp_YourSproc"
cmd.CommandType = adCmdStoredProc
cmd.CommandTimeout = 30

With cmd
.Parameters.Append cmd.CreateParameter("@intData", adInteger, adParamInput, , intData)
cmd.Execute
End With
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top