Executing a Parameterized Stored Procedure : Stored Procedure « Access « VBA / Excel / Access / Word






Executing a Parameterized Stored Procedure

 
Sub Execute_StoredProcWithParam() 
    Dim conn As ADODB.Connection 
    Dim strCompany As String 
    Dim strPhone As String 

    On Error GoTo ErrorHandler 

    Set conn = CurrentProject.Connection 

    strCompany = "nnn"
    strPhone = "123123"
    If strCompany <> "" And strPhone <> "" Then 
        conn.Execute "procName " & strCompany & ", " & strPhone 
    End If 

ExitHere: 
    If Not conn Is Nothing Then 
        If conn.State = adStateOpen Then conn.Close 
    End If 
    Set conn = Nothing 
    Exit Sub 
ErrorHandler: 
    Debug.Print Err.Number & ":" & Err.Description 
    Resume ExitHere 
End Sub 

 








Related examples in the same category

1.Create a stored procedure
2.Call store procedure
3.Use the EXECUTE statement to execute the stored procedure
4.Creating a Stored Procedure that Accepts Parameters
5.Deleting a Stored Procedure
6.Executing a Stored Procedure Containing Parameters