Link to home
Start Free TrialLog in
Avatar of vwalla
vwalla

asked on

Create Dataset from SQL CE Database

Is there a way to create a dataset from a sqlce database.  Basically I want to iterate through the structure of a local database on the client computer and compare it with another sqlcedb (strongly typed so that is easy) to update any column or table changes.
 Here is all I have so far.  There are never any tables in the collection, so I beleive I need to "populate" the schema info from the database on the client machine, but I am not sure how to do it.  Thanks.
Dim sConnectionString As String
        sConnectionString = "Data Source=" & My.Settings.DBLocation

        Dim objConn As New SqlCeConnection(sConnectionString)
        objConn.Open()


        Dim dsUserDB As New DataSet("UserDB")

       
       
        Dim table As DataTable
        For Each table In dsUserDB.tables
            Console.WriteLine(table.TableName)
        Next

Open in new window

Avatar of RameshS
RameshS
Flag of India image

Try the following code.

Refer Information Schema (SQL Server Compact)

 SqlCeConnection cn = new SqlCeConnection("YourConnectionString");
            SqlCeDataAdapter da = new SqlCeDataAdapter("SELECT * FROM INFORMATION_SCHEMA.TABLES", cn);
            DataTable dt = new DataTable();
            da.Fill(dt);
            foreach (DataRow row in dt.Rows)
            {
                Console.WriteLine("Table Name : " + row["TABLE_NAME"].ToString());
            }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of RameshS
RameshS
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vwalla
vwalla

ASKER

Perfect!  Thanks.  I can figure out iterating the columns from here http://msdn.microsoft.com/en-us/library/ms188348.aspx.

Thanks again!