Help with understanding ADO

deadseasquirrels

Board Regular
Joined
Dec 30, 2004
Messages
232
Some very gracious people have been helping me with trying to use VBA to hit an oracle database. I've gotten as far as this code below:

Code:
Private Sub SQLTest()

    Dim dbsNDF As New ADODB.connection
    Dim connString As String
    Dim dbRS As Object
    Dim sqlString As String
    
    connString = "Provider=MSDAORA.1;Password=[pwd];User ID=[id];Data Source=DKARCH1.WORLD;Persist Security Info=True"
    dbsNDF.connectionString = connString
    dbsNDF.Open

    sqlString = "Select SO.STUDENT.LAST_NAME FROM SO.STUDENT WHERE First_Name = 'Michelle' and LAST_NAME like 'De%'"
'    Debug.Print MsgBox(sqlString)
 '   Stop
    
    Set dbRS = dbsNDF.Execute(sqlString)
    
    Cells(106, 1).CopyFromRecordset dbRS
    
    If dbRS.EOF And dbRS.BOF Then
        MsgBox "End of File"
        GoTo CleanUpAndClose
    Else

        dbRS.MoveFirst
        Do While Not dbRS.EOF
            If dbRS.RecordCount = 0 Then
                MsgBox ("empty")
            End If
            MsgBox (dbRS.Fields(1).Value)
            dbRS.MoveNext
        Loop
    End If
    
CleanUpAndClose:
    dbRS.Close
    dbsNDF.Close
    Set dbRS = Nothing
    Set dbsNDF = Nothing
End Sub
with very simple SQL scripts the above script works. But now the SQL string that is in there right now. I don't know what technology this is even, is this ADO? Whatever it is, I'd like to learn more, so that I can more properly debug the issues myself. For example right now I have no idea what
Code:
 If dbRS.EOF And dbRS.BOF Then
        MsgBox "End of File"
        GoTo CleanUpAndClose
    Else

        dbRS.MoveFirst
        Do While Not dbRS.EOF
            If dbRS.RecordCount = 0 Then
                MsgBox ("empty")
            End If
            MsgBox (dbRS.Fields(1).Value)
            dbRS.MoveNext
        Loop
    End If
that whole section is about. If somebody can give me a hand, explain, or even point me to some documents that can explain I would greatly appreciate it. Thank you.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
If you put the cursor into a command word in the VB Editor and press F1 key then you get help.

Also have a look at View/Object Browser. You can use F1 there too.

Otherwise use the Help menu.

Do a Google seach on terms/keywords.

I have learned more this way than any other.
 
Upvote 0
May I suggest that You buy a book on the subject.

Books are still indeed highly valuable as sources for good knowledge.

The advantage compared with online resources is that books have been reviewed both by the publishers as well as people with high technicall skillness & knowledge.

You find two good books here for ADO:
http://www.excelkb.com/article.aspx?id=10142&cNode=7D1Y4I


You can also search for the ADO210.chm file on Your local drive as a start.
 
Upvote 0
The website wiht the list of books is a helpful resource, I'll look those books up. Thanks.

However I've always felt the internet was actually the best place. I found an equal amount of errors from what I've read in printed form as what I've read on the internet, but I find the internet is more up to date, and the people who decide to put something up on the internet usually use more real-life examples, and colloquial speak. Much like reading financial books, the internet is just more up to date.

There may not be many java developers here, but if there are, I think they would agree that the internet and the sun site is by far better than 95% of the books out there (there are actually books that are just printed version of the site). But thanks for the suggestion anyhow.
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,409
Members
448,959
Latest member
camelliaCase

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top