Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 26th, 2008, 11:49 AM
Registered User
 
Join Date: Sep 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default QueryTables.Add - Sql parameter question

I'm trying to execute the following code to add new records from a text file to an already created table but I get a SQL syntaxis error.

sqltext = "LOAD DATA LOCAL INFILE 'C:\SIG\plaintext.txt' INTO TABLE pruebas FIELDS TERMINATED BY '|' LINES STARTING BY '!' TERMINATED BY '\r\n'"

With ActiveSheet.QueryTables.Add(Connection:= _
        "ODBC;DATABASE=database;DSN=dsngen;OPTION=0;PORT=0 ;SERVER=mainframe;UID=userid;PWD=default", _
        Destination:=Range("dam2"), Sql:=sqltext)
        '.CommandText = Array(sq)
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .PreserveColumnInfo = True
        .Refresh BackgroundQuery:=True
    End With
End If

Hope anyone can help me because I tried to execute a SQL query with the following line:

sqltext=SELECT * from pruebas

and it worked.






Similar Threads
Thread Thread Starter Forum Replies Last Post
QueryTables.Add... name changes peacefullAnd4getfull Excel VBA 0 May 14th, 2007 01:06 PM
Add parameter to "navigation" url - roy_mm Reporting Services 1 October 16th, 2006 07:00 AM
Add a parameter to a pop up window NEO1976 Javascript 3 August 2nd, 2006 08:42 AM
Help for (with ActiveSheet.QueryTables.Add Connec) chintu4u Excel VBA 0 June 13th, 2006 01:11 AM
Add default value to a parameter in a query marcin2k Access VBA 2 February 18th, 2005 04:39 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.