.CommandText = "SELECT Bancos.Codigo_banco, Bancos.Nome_banco, FROM Atuante.dbo.Bancos Bancos"
The Excel macro:With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _ "ODBC;DSN=Atuante;Description=conexão ao BD da atuante p/ gerar SP;UID=XX;PWD=XXX;APP=Microsoft® Query;WSID=BXXB;DATABASE=Atuante;LANG" _ ), Array("UAGE=Português")), Destination:=Range("A1")) .CommandText = Array( _ "SELECT Bancos.Codigo_banco, Bancos.Nome_banco, Bancos.Numero_banco" & Chr(13) & "" & Chr(10) & "FROM Atuante.dbo.Bancos Bancos" _ ) .Name = "Consulta de Atuante" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = True .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .PreserveColumnInfo = True .Refresh BackgroundQuery:=False End WithIn VFP:
LOCAL oExcel AS 'Excel.Application' oExcel = CREATEOBJECT('Excel.Application') oExcel.SheetsInNewWorkbook = 1 oWorkbook = oExcel.Workbooks.ADD oActiveSheet = oExcel.ActiveSheet oActiveSheet.NAME = "teste" connstringx = "ODBC;DSN=atuante;UID=XX;PWD=XX;Database=Atuante" WITH oActiveSheet.QueryTables.ADD(connstringx,'A1:A1') .NAME = "Contact List" .CommandText = "??? <<<<<<========== ???" .FieldNames = .T. .RowNumbers = .F. .FillAdjacentFormulas = .F. .PreserveFormatting = .T. .RefreshOnFileOpen = .F. .BackgroundQuery = .T. .SavePassword = .T. .SaveData = .T. .AdjustColumnWidth = .T. .RefreshPeriod = 0 .PreserveColumnInfo = .T. .REFRESH BackgroundQuery = .F. ENDWITH oExcel.VISIBLE = .T.Any ideias how to get the SQLStatement ?