Home All Groups Group Topic Archive Search About

import data from sql to excel using vb.net

Author
29 Aug 2006 8:59 AM
Deep
i whould u like to import data from sql server database into excel
sheet using vb.net

Author
30 Aug 2006 3:44 PM
Paul Clement
On 29 Aug 2006 01:59:54 -0700, "Deep" <deep8***@gmail.com> wrote:

¤ i whould u like to import data from sql server database into excel
¤ sheet using vb.net

Below is one method you can use:

        Dim ExcelConnection As New
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
                                                                    "Data Source=" & "c:\Test
Files\ExcelWB.xls" & ";" & _
                                                                    "Extended Properties=Excel
8.0;")

        ExcelConnection.Open()

        Dim ExcelCommand As New System.Data.OleDb.OleDbCommand("SELECT * INTO [Orders] FROM [Orders]
IN '' [ODBC;Driver={SQL Server};Server=(local);Database=Northwind;Trusted_Connection=yes];",
ExcelConnection)

        ExcelCommand.ExecuteNonQuery()
        ExcelConnection.Close()


Paul
~~~~
Microsoft MVP (Visual Basic)