views:

233

answers:

1

HI All,

I've succesfully synchronized both source and local db using the local database cache item in VS 2008.

However, I need to access the SQL CE db directly from within another dll/process, and not using a dataset. Reason being my business object code does not use datasets. code would look something like this:

Dim conn As New SqlServerCe.SqlCeConnection("Data Source=C:\Development\UserDirectory\UserDirectory.DBSyncher\ProfDir.sdf;Persist Security Info=False;")

Dim cmd As New SqlServerCe.SqlCeCommand("Select EmailAddress from Employees Where ID=23", conn)

Dim returnString As String = ""

    If conn.State = ConnectionState.Closed Then
        conn.Open()
    End If
    returnString = cmd.ExecuteScalar

    conn.Close()
    cmd = Nothing

I notice something very strange using a dataset the synchronized changes are shown but accessing the CE database file directly returns old data - no synched data whatsoever.

What am i missing? any help would be greatly appreciated.

Thanks!

+1  A: 

Figured it out!

Forgot that CE is in process, thus it copies the database file(.sdf) to the Debug folder. You have to to reference that database not the one in your project. DOH!