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

  • Home
  • SEARCH
  • 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 98149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:08:27+00:00 2026-05-11T00:08:27+00:00

How can I get a DataSet with all the data from a SQL Express

  • 0

How can I get a DataSet with all the data from a SQL Express server using C#?

Thanks

edit: To clarify, I do want all the data from every table. The reason for this, is that it is a relatively small database. Previously I’d been storing all three tables in an XML file using DataSet’s abilities. However, I want to migrate it to a database.

  • 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. 2026-05-11T00:08:28+00:00Added an answer on May 11, 2026 at 12:08 am

    You can use the GetSchema method to get all the tables in the database and then use a data adapter to fill a dataset. Something like this (I don’t know if it compiles, I just paste some code and change it a bit):

    DbProviderFactory factory = DbProviderFactories.GetFactory('System.Data.SqlClient');  DataTable tables = null; DataSet database = new DataSet();  using (DbConnection connection = factory.CreateConnection()) {      connection.ConnectionString = 'Data Source=(local);Initial Catalog=Northwind;Integrated Security=True';      string[] restrictions = new string[4];      // Catalog     restrictions[0] = 'Northwind';      // Owner     restrictions[1] = 'dbo';      // Table - We want all, so null     restrictions[2] = null;      // Table Type - Only tables and not views     restrictions[3] = 'BASE TABLE';      connection.Open();      // Here is my list of tables     tables = connection.GetSchema('Tables', restrictions);      // fill the dataset with the table data     foreach (DataRow table in tables.Rows)     {          string tableName = table['TABLE_NAME'].ToString();          DbDataAdapter adapter = factory.CreateDataAdapter();         DbCommand command = factory.CreateCommand();         command.Connection = connection;         command.CommandType = CommandType.Text;         command.CommandText = 'select * from [' + tableName + ']';         adapter.SelectCommand = command;         adapter.Fill(database, tableName);      }  } 

    EDIT:

    Now I refactored it a bit and now it’s working as it should. The use of DbConnection and DbProviderFactories is for database engine abstraction, I recommend using it so you can change the database engine changing this line and the connection string:

    DbProviderFactory factory = DbProviderFactories.GetFactory('System.Data.OracleClient'); 

    The GetSchema method will retrive all tables from your database to a DataTable and then we get all the data from each table to the DataSet using the DataAdapter.

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

Sidebar

Ask A Question

Stats

  • Questions 93k
  • Answers 93k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer var query = from q in session.Linq<Person>() where q.FirstName.StartsWith(firstName) &&… May 11, 2026 at 6:38 pm
  • Editorial Team
    Editorial Team added an answer Thanks for the suggestion. The way that I ended up… May 11, 2026 at 6:38 pm
  • Editorial Team
    Editorial Team added an answer I can't determine why the UserControl isn't properly formatting the… May 11, 2026 at 6:38 pm

Related Questions

How can I use Linq with Dataset.xsd files? I've looked at Linq-to-Datasets and Linq-to-XSD
I've imported a csv file with lots of columns and sections of data. v
I have a winform application that uses some referenced web services to get data.
Newbie to .NET data apps here, coming from a Visual Foxpro background. I'm planning

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.