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

LVL 1
vwallaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RameshSCommented:
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

0
RameshSCommented:
VB.NET version of the above code.

Imports System.Data
Imports System.Data.SqlServerCe

Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim cn As SqlCeConnection = New SqlCeConnection("YourConnectionString")
        Dim da As SqlCeDataAdapter = New SqlCeDataAdapter("SELECT * FROM INFORMATION_SCHEMA.TABLES", cn)
        Dim dt As DataTable = New DataTable()
        da.Fill(dt)
        For Each row As DataRow In dt.Rows
            Console.WriteLine("Table Name : " & row("TABLE_NAME").ToString())
        Next
    End Sub
End Class

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vwallaAuthor Commented:
Perfect!  Thanks.  I can figure out iterating the columns from here http://msdn.microsoft.com/en-us/library/ms188348.aspx.

Thanks again!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.