ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SELECT * INTO[Text;DATABASE... (https://www.excelbanter.com/excel-programming/412833-select-%2A-into%5Btext%3Bdatabase.html)

cg

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


All times are GMT +1. The time now is 04:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com