April15Hater
Accountant
- Local time
- Yesterday, 22:02
- Joined
- Sep 12, 2008
- Messages
- 349
Hi Guys-
I know most of you are access experts, but I have a problem with an oracle database. I'm using Excel VBA to tap an Oracle DB via ADO. My problem is that .EOF takes a really long time. Wondering if there are any suggestions on how to speed this up...? Code is below, and my problem begins at the line- "If .EOF Then NoErrors = True"
I know most of you are access experts, but I have a problem with an oracle database. I'm using Excel VBA to tap an Oracle DB via ADO. My problem is that .EOF takes a really long time. Wondering if there are any suggestions on how to speed this up...? Code is below, and my problem begins at the line- "If .EOF Then NoErrors = True"
Code:
Public Function OpenADOConnection()
Dim cnProductionDatabase As ADODB.Connection
Dim dbConnection As String
'DEFINE LOCATION OF THE DATABASE
dbConnection = "Provider=MSDAORA.1; Password=focus; User ID=cis; Data Source=" & Left(Worksheets("Main Sheet").Range("C6"), 4)
'Open the DB connection
If cnProductionDatabase Is Nothing Then
Set cnProductionDatabase = New ADODB.Connection
cnProductionDatabase.Open dbConnection
End If
Set OpenADOConnection = cnProductionDatabase
End Function
Function StrandAddVsHouse(MapNumber As String, RecordNumber As Long) As Variant
Dim rsOracle As ADODB.Recordset
Dim IntX As Long
Dim pRecordNumber As Integer
Dim NoErrors As Boolean
Dim rsArray(0 To 4)
Set rsOracle = New ADODB.Recordset
With rsOracle
.ActiveConnection = OpenADOConnection
.CursorType = adOpenDynamic
.LockType = adLockReadOnly
.Source = "SELECT hscount.mapname, hscount.mslink, count(address.hcmslink) AS CountHC, hscount.act_count, poleped.cell_name " _
& "FROM Address, hscount, poleped " _
& "WHERE address.hcmslink= hscount.mslink(+) and poleped.mslink= hscount.pole_link and hscount.mapname = '" & UCase(MapNumber) & "' " _
& "GROUP BY hscount.mapname, hscount.mslink, hscount.act_count, poleped.cell_name " _
& "HAVING count(address.hcmslink)<> hscount.act_count and poleped.cell_name<> 'PLENUL' "
.Open
For IntX = 1 To RecordNumber
If .EOF Then NoErrors = True
If Not .EOF Then .MoveNext
Next IntX
.Close
.Open
Do Until .EOF Or pRecordNumber = RecordNumber
rsArray(0) = !MapName
rsArray(1) = !mslink
rsArray(2) = !CountHC
rsArray(3) = !Act_Count
rsArray(4) = !Cell_Name
pRecordNumber = pRecordNumber + 1
.MoveNext
Loop
If NoErrors Then rsArray(0) = "END"
StrandAddVsHouse = rsArray
End With
End Function