Executing a stored procedure?

  • Thread starter Thread starter Gene S.
  • Start date Start date
G

Gene S.

Hello,

How do I call(execute) a stored procedure using code in an
event within a .adp?

Any help would be greatly appreciated!
Thanks in advance
 
The easiest way is to use ADO; for example:

Dim cmd As ADODB.Command
Set cmd = New ADODB.Command

cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "dbo.MyStoredProcedure"
cmd.Parameters.Append cmd.CreateParameter("@IdLigue", adInteger,
adParamInput, , IdLigue)
cmd.Execute , , adExecuteNoRecords

and here another one, still using the previous Cmd object :
....
cmd.CommandType = adCmdText
cmd.CommandText = "select * from dbo.MyTable where ..."

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open cmd, , adOpenStatic, adLockReadOnly

S. L.
 
If your stored procedure is simple, you may also launch it as a sql
procedure:
docmd.runsql("....")
from queries, select new; design stored procedure. design your procedure.
You may obtain the .... from the icon SQL on the stored procedure design
menu (between icons grid and very sql syntax)
This is ok for simple procedures only.
 
Back
Top