am trying to use Microsoft Query tool of Excel with
VB.NET. Actually i want to take data from SQL server to Excel using
this tool. I am doing Programming through VB.NET. So any one can tell
me how to do that? Actually in VB we can do the same thing using
following code.
With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;DRIVER=SQL Server;SERVER=(local);UID=;APP=Microsoft®
Query;WSID=SERVERNAME;DATABASE=riya;Trusted_Connection=Yes" _
, Destination:=Range("B1"))
.CommandText = Array( _
"SELECT TEMPTABLE.POPESTIMATE2000, TEMPTABLE.POPESTIMATE2001,
TEMPTABLE.POPESTIMATE2002, TEMPTABLE.POPESTIMATE2003,
TEMPTABLE.POPESTIMATE2004" & Chr(13) & "" & Chr(10) & "FROM
Riddhi.dbo.TEMPTABLE TEMPTABLE" _
)
.Name = "Query from RIDDHI"
.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 With
But in VB.net I cann't find any such properties like
querytable as in above case. So if any one having this idea then tell
me the code.