0
成果轉化的工具,我正在寫一個工具導入數據庫查詢結果到Excel中VB.NET導入查詢通過VB.NET
我嘗試下面的代碼。它不工作。
With objApp.ActiveSheet.QueryTables.Add(Connection:="ODBC;DSN=Build_statistics;", _
Destination:=objApp.Range("G15"))
.CommandText = "SELECT * from mytable"
.Name = "Query"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = Microsoft.Office.Interop.Excel.XlCellInsertionMode.xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
**.Refresh(BackgroundQuery:=False)** 'I am getting error here
End With
它在VBA中工作正常,但在VB.NET中沒有問題。
VBA不是VB.NET,它們是非常不同的語言。 – Oded 2010-02-08 11:01:19