Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling Procedure in Class

Status
Not open for further replies.

scottsanpedro

Programmer
Apr 26, 2002
97
GB
Hi,
I have a simple call to an ADO subroutine that refreshes a recordset from SQL SERVER 2005 to my ACCESS 2007 DB.
Code:
Set cmd = New ADODB.Command
    cmd.ActiveConnection = gcnn
    cmd.CommandType = adCmdStoredProc
    cmd.CommandText = mCommandText
    
    Set rstServer = New ADODB.Recordset
    rstServer.CursorLocation = adUseClient
    rstServer.CursorType = adOpenKeyset
    rstServer.Open cmd
    
    Set Form_subfrmRenewalErrors.Recordset = rstServer
    Form_subfrmRenewalErrors.Requery
    
    Set cmd = Nothing
    Set rstServer = Nothing
Notice that there is a variable 'mCommandText' in the cmd.CommandText.
All I want to do is pass the name of the SP across to the class and it to run. But I'm getting errors.
Automating a general ADO call via a class.
Thanks if you can help
Scott
 
How have you tried to pass the command text to the class that gives you errors?

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
I'm trying to pass the text to the CommandText. It works if I hard code the SP names, in this case as follows (calling procedure from form)
Code:
Dim ClearLog As clsRenewals

Set ClearLog = New clsRenewals

ClearLog.CommandText = "CM_PROCESS_ERROR_LOG_CLEAR"
ClearLog.ClearErrorLog
 
to make myself clear.
If I hardcode the CommandText in the Class, then it works fine. Passing the string variable creates an error!
Scott
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top