Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello guys,
I have this connection how to get several recordset from this connection Sub GetconnectionADOBD() Dim cndb As ADODB.Connection, cndb1 As ADODB.Connection Set cndb = New ADODB.Connection Set cndb1 = New ADODB.Connection cndb.ConnectionString = CONNECTION cndb.Open If cndb.State = adStateOpen Then End If End Sub How can I define my Sub. I would to call this function and they ask for a connection Sub recordsetMacro1() Sub RecordSetMacro2 () Ina |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Nor sure what the problem is:
If you want recordsets (DQL subset of SQL) only, use recordset objects only: set RS1 = CreateObject("ADODB.Recordset") RS1.Open "SELECT * FROM MYTABLE", "MYConnectionString" RS1.Open "SELECT * FROM MYTABLE2", "MYConnectionString" i.e you do not need a connection object to open a recordset, just a connection string. IF you want to use a connection object: SET CN = CreteObject("ADODB.Connection") CN.Open "MyconnectionString") SET RS = CreteObject("ADODB.RecordSet") RS1.Open "your SQL statement", CN RS2.Open "your SQL statement", CN With the latter approach, you have 2 objects to manage. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks I would like to do like this
Function GetConnectionADOBD( ) As ADOBD.Connection ' I have an error here Dim cndb As ADODB.Connection, cndb1 As ADODB.Connection cndb.ConnectionString = "CONNECTION" cndb.Open cndb2 = GetConnectionADODB End Function Sub GetRecordSet () Dim cndb As ADODB.Connection Dim rsAs ADODB.Recordset Dim strSQL As String Set cndb = New ADODB.Connection Set rs = New ADODB.Recordset cndb = GetConnectionADOBD 'from my function ...... End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Should Function GetConnectionADOBD( ) As ADOBD.Connection be Function GetConnectionADOBD( ) As ADODB.Connection DB not BD "ina" wrote: Thanks I would like to do like this Function GetConnectionADOBD( ) As ADOBD.Connection ' I have an error here Dim cndb As ADODB.Connection, cndb1 As ADODB.Connection cndb.ConnectionString = "CONNECTION" cndb.Open cndb2 = GetConnectionADODB End Function Sub GetRecordSet () Dim cndb As ADODB.Connection Dim rsAs ADODB.Recordset Dim strSQL As String Set cndb = New ADODB.Connection Set rs = New ADODB.Recordset cndb = GetConnectionADOBD 'from my function ...... End Sub |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Oupps Thank you :) little tired now
|
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Put "Option Explicit" at the top of *every* code module. It will highlight a lot of your problems.
Function GetConnectionADODB( ) As ADODB.Connection Dim cndb As new ADODB.Connection cndb.ConnectionString = "CONNECTION" cndb.Open set GetConnectionADODB = cndb End Function -- Tim Williams Palo Alto, CA "ina" wrote in message ups.com... Thanks I would like to do like this Function GetConnectionADOBD( ) As ADOBD.Connection ' I have an error here Dim cndb As ADODB.Connection, cndb1 As ADODB.Connection cndb.ConnectionString = "CONNECTION" cndb.Open cndb2 = GetConnectionADODB End Function Sub GetRecordSet () Dim cndb As ADODB.Connection Dim rsAs ADODB.Recordset Dim strSQL As String Set cndb = New ADODB.Connection Set rs = New ADODB.Recordset cndb = GetConnectionADOBD 'from my function ..... End Sub |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
thanks a lot guys now seems that I understood much better. :)
my problem is more how to call function with VBA with set such as set getConnectionADODB = cndb, but now I thing I understood. Ina |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|