Sub CreateStoredProc()
Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = "CREATE PROCEDURE procClientGet " & _
"(CID long) " & _
"AS SELECT ClientID, CompanyName " & _
"FROM tblClients " & _
"WHERE ClientID = CID"
cmd.Execute
End Sub
Sub ExecuteStoredProc()
Dim rst As ADODB.Recordset
Dim cmd As Command
Set cmd = New ADODB.Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = "EXECUTE procClientGet 1"
Set rst = cmd.Execute
MsgBox rst("CompanyName")
End Sub
|