tags:

views:

5

answers:

1

Hi

 I am trying to connect to oracle database from excel..now this is working
 fine when i manually create the DSN..but now i want to create DSN
 programmtically using vb..Please help me i am new to vbscripting...

Thanks in advance
A: 

Here is some sample code:

Dim objConn
Set objConn = CreateObject("ADODB.Connection")

Dim connString
connString = "YOUR ORACLE CONNECTION STRING HERE!"

objConn.Open connString

Dim objRS
Dim strSQL
strSQL = "SELECT * FROM YourTable"

Set objRS = objConn.Execute(strSQL)
If objRS.EOF Then
    ' No Records Returned
Else
    Do
             ' Do what you want with your output
        objRS.MoveNext
    Loop Until objRS.EOF
End If
End With

objRS.Close
Set objRS = Nothing


objConn.Close
Set objConn = Nothing

Use the Oracle Connection Strings page to find your connection string. This is VBScript, for VB you may have to make a few changes such as defining your variable types.

Dim strSQL As String
DaveB