F
FA
Hi All,
I need to execute the stored procedure taking a input parameter @ID
from a text box control of frmTest and on the same form theere is
command button to run the SP and view the results.
I tried the following to test the stored procedure calling but it is
not opening the results set in a query.
Dim objConn As New ADODB.Connection
Dim objCmd As New ADODB.Command
Dim objParm1 As New ADODB.Parameter
Dim objRs As New ADODB.Recordset
Dim strCnxn As String
' Set CommandText equal to the stored procedure name.
objCmd.CommandText = "spTest"
objCmd.CommandType = adCmdStoredProc
' Connect to the data source.
strCnxn = "Provider='SQLOLEDB';Data Source='TestServer';" & _
"Initial Catalog='ABC';User ID='XYZ';Password='p123';"
objConn.open strCnxn
' Automatically fill in parameter info from stored procedure.
objCmd.Parameters.Refresh
' Set the param value.
objCmd(1) = Me.txtAbc.value
' Execute once and display...
Set objRs = objCmd.Execute
End If
The above codes are behind a command button and when i click on it,
nothing happen. It suppose to open up the results or the stored
procedure in the query but it does not do anything.
I need to execute the stored procedure taking a input parameter @ID
from a text box control of frmTest and on the same form theere is
command button to run the SP and view the results.
I tried the following to test the stored procedure calling but it is
not opening the results set in a query.
Dim objConn As New ADODB.Connection
Dim objCmd As New ADODB.Command
Dim objParm1 As New ADODB.Parameter
Dim objRs As New ADODB.Recordset
Dim strCnxn As String
' Set CommandText equal to the stored procedure name.
objCmd.CommandText = "spTest"
objCmd.CommandType = adCmdStoredProc
' Connect to the data source.
strCnxn = "Provider='SQLOLEDB';Data Source='TestServer';" & _
"Initial Catalog='ABC';User ID='XYZ';Password='p123';"
objConn.open strCnxn
' Automatically fill in parameter info from stored procedure.
objCmd.Parameters.Refresh
' Set the param value.
objCmd(1) = Me.txtAbc.value
' Execute once and display...
Set objRs = objCmd.Execute
End If
The above codes are behind a command button and when i click on it,
nothing happen. It suppose to open up the results or the stored
procedure in the query but it does not do anything.