|
-
May 2nd, 2001, 09:32 AM
#1
Thread Starter
PowerPoster
To pass the conn object or not? That is the question.
With this code, how do I pass the conn object to another class module?
The name of the function that needs to receive the conn object is
Code:
Public Function Get_Search_RS(conn As ADODB.Connection, rsRecordset As ADODB.Recordset, strTitle As String, strCat As String, strFileX As String, strFileName As String) As String
Code:
Public Sub GetConn2()
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Sms001\Shared\web\Internet\Graphic_Search\dbGraphics.mdb;Persist Security Info=False"
conn.CursorLocation = adUseClient
conn.Open
End Sub
-
May 2nd, 2001, 09:36 AM
#2
Addicted Member
how abt using a property for the connection object and then use it in the class module as normal?
-
May 2nd, 2001, 09:38 AM
#3
Thread Starter
PowerPoster
Not sure what you mean? Can you show me an example please?
-
May 2nd, 2001, 10:03 AM
#4
PowerPoster
They may help ya, I pass a connection object, and return a recordset. This is a class mod:
Code:
Public Function GetAllStates(ByRef objConn As ADODB.Connection) As Recordset
'// Declare local objects
Dim objRS As New ADODB.Recordset
'// Setup error handling
On Error GoTo GetAllStates_EH
'// Set recordset cursor location and open recordset
objRS.CursorLocation = adUseClient
objRS.Open "up_select_state_name", objConn, adOpenStatic, adLockReadOnly, adCmdStoredProc
'// Disconnect recordset
Set objRS.ActiveConnection = Nothing
'// Return with the recordset
Set GetAllStates = objRS
Set objRS = Nothing
'// All was successful, exit function
On Error GoTo 0
Exit Function
GetAllStates_EH:
Set GetAllStates = Nothing
Set objRS = Nothing
On Error GoTo 0
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|