Efficient way of opening Excel and displaying result set from a SQL Server table in v

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MIkeC
    New Member
    • Jan 2008
    • 8

    Efficient way of opening Excel and displaying result set from a SQL Server table in v

    I am new to quite new vb net 2005 and want to read a sql server table and load the result set directly into excel. I want the worksheet to be opened and display the column headers and data from the query.
    In VB6 it was possible to declare a Querytable and I am wondering if there is an equivalent in .Net
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Well, there is an object called DataGridView that gives you an Excel like spreadsheet. That's the easiest way to get a table's data into a spreadsheet.

    But if you want to go directly into Excel, that will take some work. Check out this MSDN article. It shows you how to use COM to add data to an Excel spreadsheet.

    Also, read this article on using a database in your program. I would also suggest looking up how to use a SqlDataAdapter, because instead of a data reader, it gives you a DataTable full of your query results.

    If you need some help on the SqlDataAdapter or anything else, let us know.

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      You can also connect to Excel using ADO.NET

      Comment

      Working...