View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
cg cg is offline
external usenet poster
 
Posts: 11
Default SELECT * INTO[Text;DATABASE...

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!!!