pass parameter to SQL

S

smk2

Hello there!
I am trying to pass a parameter to SQL server 2k from Access 2002:
Here is my code so far which compiles okay.
Question is: if the SQL parameter is called @nApptID, does that need to be somewhere in my
VBA code, or how do I tell the SP what parameter I am passing it?

Private Sub cmdEnter_Click()
Dim oCn As ADODB.Connection
Dim oCmd As New ADODB.Command
Dim oPr As New ADODB.Parameter

On Error GoTo Error_Handler

' Get a Connection Object to the SQL Database
Set oCn = CurrentProject.Connection

oCmd.CommandType = adCmdStoredProc

' Set value of parameter to pass to SP
Set oPr = oCmd.CreateParameter("AppointmentID", adInteger, adParamInput, , Me.AppointmentID)
oCmd.Parameters.Append oPr 'add to collection

' execute the stored procedure
oCn.Execute "procApptOvDetailUpdate"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top