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