Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleOpen an Oracle database using ADO
KeywordsADO, Oracle, database, connect
CategoriesDatabase
 
Use a connect string as in:
 
Dim conn As ADODB.Connection

    ' Open a connection using Oracle ODBC.
    Set conn = New ADODB.Connection
    conn.ConnectionString = _
        "Driver={Microsoft ODBC for Oracle};" & _
        "UID=user_name;PWD=user_passsword"
    conn.Open
 
Open the table as in:
 
Dim rs As ADODB.Recordset

    ' Open the table.
    Set rs = New ADODB.Recordset
    rs.Open "TableName", conn, adOpenDynamic, _
        adLockOptimistic, adCmdTable
 
Note that you need to fill in a valid user name, password, and table for your database.

Note also that this example uses the Microsoft ODBC driver for Oracle. Oracle also supplies drivers that you may be able to use instead.

This example reads the data from the table and displays the values in a ListBox.

 
    ' List the data.
    Do While Not rs.EOF
        txt = ""
        For Each fld In rs.Fields
            txt = txt & Trim$(fld.Value) & ", "
        Next fld
        If Len(txt) > 0 Then txt = Left$(txt, Len(txt) - 2)
        List1.AddItem txt
        rs.MoveNext
    Loop

    rs.Close
    conn.Close
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated