|
Hi all VB developers !
Pls. refer to the following code-block. Can any1 arrange the ADO connection logic for this VBA code-block ?
Set mdxRec = New ADODB.Recordset
If dbh = "" Then
' MsgBox ("Faild")
End If
'dbh.ConnectionTimeout = 360000
Set mdxRec.ActiveConnection = dbh
mdxRec.Source = strMDX
On Error GoTo errHand
mdxRec.Open
dbh.ConnectionTimeout = 360000
' ADDED RECENTLY
''If dbh.Close = False Then
If dbh.State = 1 Then
dbh.Close
End If
On Error GoTo errHand
Set wbBook = ThisWorkbook
Set wkSheet = wbBook.Worksheets(1)
'Read in values from the record set
wkSheet.Cells(9, 1).CopyFromRecordset mdxRec
SubTotalsIns 9, 2, 3, 4, 8, 9, StartDate, EndDate
mdxRec.Close
CloseDBConnection
I have tried to arrange the steps/sequence but faced a lot of errors and
I am primarily a VB.NET guy so I dunno how one really goes about doing it in VBA. Can some1 with VBA background help me sort this out ?!
Thanks in Advance
|