SELECT * INTO[Text;DATABASE...

C

cg

All,

I am in EXCEL trying to use ADO to connect to an Oracle table and save the
table as a text file. Here is the code I am attempting to use:

Public Sub OracleExtracttoTXT()

Dim cn As ADODB.Connection
Dim sqlString As String
Dim strConn As String

Set cn = New ADODB.Connection
strConn = "Driver={Oracle in instantclient10_1};"
strConn = strConn & "DBQ=PROD;Uid=JDoe;Pwd=Doe5;"

cn.Open strConn

sqlString = "SELECT * INTO [Text;DATABASE=C:\Documents and
Settings\JDoe\Desktop].[Test.txt] FROM GL_PERIODS"

cn.Execute sqlString
cn.Close
Set cn = Nothing
End Sub

Excel shuts down on me everytime I run this. Any ideas what I am doing wrong?

Thanks!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top