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

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

Answer Wiki

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

There is no Oracle 6<b>i</b> 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)

<pre>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
Combo1.Clear
Do Until rstemp.EOF
msgbox rstemp(0)
rstemp.MoveNext
howmany = howmany + 1
Loop
</pre>
‘ RDO Example (Remote Data Objects)
<pre>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
.MoveNext
howmany = howmany + 1
Loop
</pre>
ADO Example
<pre>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”
m_adoCnn.Open
End Sub

Private Sub Form_Unload(Cancel As Integer)
m_adoCnn.Close
End Sub
</pre>
OO4O Example
<pre>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

</pre>

In .NET you could use the <a href=”http://msdn.microsoft.com/en-us/library/system.data.oracleclient.oracleconnection.aspx”>OracleConnection Class</a>. Here is an example:

<pre>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”
Try
conn.Open()
‘ Insert code to process data.
Catch ex As Exception
MessageBox.Show(“Failed to connect to data source”)
Finally
conn.Close()
End Try
End Sub</pre>

You might also want to take a look at this link to see how it is done using ADO.NET:
<a href=”http://msdn.microsoft.com/en-us/library/ms254507.aspx”>Establishing the Connection (ADO.NET)
</a>

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

Following