Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6212889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:35:49+00:00 2026-05-24T06:35:49+00:00

I am getting data from my database and I want to have that data

  • 0

I am getting data from my database and I want to have that data as a table in excel file.
So, I have written the following :

    Dim sheetToPopulate As Excel.Worksheet = getSheet()
    Dim reader As OleDbDataReader
    Dim query As String = "SELECT * FROM dataTable"
    Dim cmd As New OleDbCommand(query, oleConn)
    Dim reader As OleDbDataReader
    oleConn.Open()
    reader = cmd.ExecuteReader()
    Do While reader.Read()
        // How use the reader to populate the sheet at once.
        // I have the sheet object as sheetToPopulate.
        // cell.Vaule = reader.GetString(0)  ' It would be very in-efficient and complex.
        // How can I dump the table to my excel sheet ?
    Loop
    reader.Close()
    oleConn.Close()

There should be a straight obvious way of doing this ?

Dumping a database table to excel sheet ?

[ Should I ? ]

Should I use dataset of something.. ? If yes, how to proceed for that ?

Please help.. I am new to this !!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:35:50+00:00Added an answer on May 24, 2026 at 6:35 am

    Here is how I solved this :

    Private Function getData(ByVal query As String, ByVal conStr As String) As Object
        Dim adapter As New Data.OleDb.OleDbDataAdapter(query, conStr)
        Dim dataSet As New Data.DataSet
        adapter.Fill(dataSet)
        Dim dataTable As Data.DataTable = dataSet.Tables(0)
        Dim data(dataTable.Rows.Count, dataTable.Columns.Count - 1) As Object
        For col = 0 To dataTable.Columns.Count - 1
            For row = 0 To dataTable.Rows.Count - 1
                data(row, col) = dataTable.Rows(row).ItemArray(col)
            Next
        Next
        Return data
    End Function
    

    Then Finally, do the following to the range where you want to have this data

    range.Value = getDate(query,conStr)
    

    That solved the whole problem !

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a table . Now, I'm interested in Getting Useful Data Easily.
Is there a best practice in getting data from multiple database tables using Zend?
I have an ssis package that imports a view from one database into different
I'm getting into dynamic data sites (remarkably powerful), and enjoying it. However, I have
We are getting an error in a VB6 application that sends data back and
Let's say I'm getting a large (2 million rows?) amount of data that's supposed
I am writing code to migrate data from our live Access database to a
I have a bound field in my Gridview which is getting its value from
i'm trying to migrate some data from two tables in an OLD database, to
I have a java program that connects to a MySql database and it's working

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.