How to display the variable that is being passed in the stored pro

G

Guest

Hi,
I got a access form from where I sending parameter to a sql server stored
procedure. I need to display the values that are being passed to the stored
procedure. How do I go about doing that in the most easiest way. Thanks

CODE:
rivate Sub cmdRunProc1_Click()

Dim conn As ADODB.Connection
'Dim cmdUpdate As ADODB.Command
Dim lngRecs
Dim strType
Dim curPercent


Set conn = New ADODB.Connection


conn.Provider = "SQLOLEDB"


conn.ConnectionString = "Provider=SQLOLEDB.1;Initial Catalog=pubs;Data
Source=USILDEK1-21001;User ID=sa;Password=alloyd;"
conn.Open

Set cmdUpdate = New ADODB.Command
cmdUpdate.CommandType = adCmdStoredProc
cmdUpdate.CommandText = "usp_UpdatePrices"
Set cmdUpdate.ActiveConnection = conn




' Get the form values
strType = Forms!frmParamPassing_mod!txtBookType
curPercent = Forms!frmParamPassing_mod!txtPercent
curPercent1 = CCur(Forms!frmParamPassing_mod!txtPercent)

Debug.Print strType

Debug.Print curPercent1


' Add the parameters
cmdUpdate.Parameters.Append cmdUpdate.CreateParameter("@Type",
adVarWChar, adParamInput, 12, strType)
cmdUpdate.Parameters.Append cmdUpdate.CreateParameter("@Percent",
adCurrency, adParamInput, , curPercent1)

' Execute the command
cmdUpdate.Execute lngRecs, , adExecuteNoRecords

' And finally tell the user what's happened

MsgBox ("Procedure complete. Records were updated")

Set conn = Nothing
Set cmdUpdate = Nothing
End Sub
 
G

Guest

Something like this:

MsgBox ("Procedure complete. Records were updated" & vbcrlf & _
"Parameter 1: " & strType & vbcrlf & "Parameter 2: " & curPercent1)
 
G

Guest

Thanks Steve for the help. I appreciate it.

SteveM said:
Something like this:

MsgBox ("Procedure complete. Records were updated" & vbcrlf & _
"Parameter 1: " & strType & vbcrlf & "Parameter 2: " & curPercent1)
 

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