Search code examples
c#ado.netdatasetsql-server-ce

SQL Server CE and C#; Populate a DataSet with ALL the Tables from a SQL Server CE DB


How would I Populate a DataSet with ALL the Tables from a SQL Server CE database. Is this possible in ONE SQL select statement?

I know that I can call separate select statements with the names of the table I need data from but I need a generic solution that just dumps all the tables from the SQL Server CE database into a Dataset.

Thanks


Solution

  • SELECT 'SELECT * FROM ' + TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
    
    1. Run it to get all the queries.
    2. Run each query, dumping it in the same dataset.

    This works very easy.

    Edit: I think I also had problems trying to run multiple queries in a single go with SQL CE (even with the line terminator ;).