ODBC connectivity to Oracle 10g database from an Oracle 6i client

Database connectivity
Oracle 10g
Oracle 6i
Visual Basic
Talking through VB Code from a Oracle 6i Client to a 10G database using ODBC.
Related Questions

Answer Wiki

Thanks. We'll let you know when a new response is added.

There is no Oracle 6i version (database). I guess you are talking about a Developer 6i client.

There are many ways to connect from Visual Basic to oracle databases.

Here are some examples (you didn’t mention what is your VB version):

‘ DAO Example (Data Access Objects)

Dim wstemp As Workspace
Dim dbtemp As Database
Dim rstemp As Recordset

Set wstemp = DBEngine.Workspaces(0)
Set dbtemp = wstemp.OpenDatabase("", False, False, "ODBC;DSN=Oracle;USR=scott;PWD=tiger")
Set rstemp = dbtemp.OpenRecordset(myquery.Text, dbOpenDynaset, dbSQLPassThrough)
howmany = 0
Do Until rstemp.EOF
msgbox rstemp(0)
howmany = howmany + 1

‘ RDO Example (Remote Data Objects)

Dim contemp As New rdoConnection
Dim rstemp As rdoResultset
Dim envtemp As rdoEnvironment
Set envtemp = rdoEngine.rdoEnvironments(0)
envtemp.CursorDriver = rdUseServer
' or rdUseOdbc, rdUseNone, rdUseIfNeeded, rdUseClientBatch
With contemp
.Connect = "ODBC;DSN=Oracle;USR=scott;PWD=tiger"
.EstablishConnection rdDriverNoPrompt, false, rdoForwardOnly
' or rdoStatic, rdoKeyset, rdoDynamic
End With

Set rstemp = contemp.OpenResultset("select ...") ' Your SQL here

howmany = 0
With rstemp
Do Until .EOF Or howmany > 2000
msgbox .rdoColumns(0) ' Popup a message box showing the 1st column
howmany = howmany + 1

ADO Example

Option Explicit

Public m_adoCnn As New ADODB.Connection
Public m_adoRst As New ADODB.Recordset

Public Sub Command1_Click()
m_adoCnn.ConnectionString = "Provider=MSDAORA;Password=tiger;User ID=scott;Data Source=database"
End Sub

Private Sub Form_Unload(Cancel As Integer)
End Sub

OO4O Example

Option Explicit

Dim m_oraSession As Object
Dim m_oraDatabase As Object

Private Sub Command1_Click()
Set m_oraSession = CreateObject("OracleInProcServer.XOraSession")
Set m_oraDatabase = m_oraSession.DBOpenDatabase("Database", "user/password", 0&)

MsgBox "Connected to " & m_oraDatabase.Connect & "@" & m_oraDatabase.DatabaseName
End Sub

Private Sub Form_Unload(Cancel As Integer)
Set m_oraDatabase = Nothing
Set m_oraSession = Nothing
End Sub

In .NET you could use the OracleConnection Class. Here is an example:

Public Sub ConnectToOracle()
Dim conn As New OracleClient.OracleConnection()
' TODO: Modify the connection string and include any
' additional required properties for your database.
conn.ConnectionString = & _
"Data Source=<oracle data source name>;Integrated Security=yes"
' Insert code to process data.
Catch ex As Exception
MessageBox.Show("Failed to connect to data source")
End Try
End Sub

You might also want to take a look at this link to see how it is done using ADO.NET: Establishing the Connection (ADO.NET)

Discuss This Question:  

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: