SQL Server Compact 3.5 Check if database has changed

Hi,
   Is there an easy way to determine if any table in an SQL Server CE 3.5 database has changed? (Any insert, update or delete in any table).
Thanks
Paul.
Paul Wainwright

 I am currently using the change tracking mechanism as the application synchronizes databases. I was considering using a FileSystemWatcher to check the LastWrite to the database file but wondered if something global in a SDF database could be used instead.
Hi Paul,
Based on my research, besides using the change tracking mechanism and FileSystemWatcher, ADO.NET SqlDependency mechanism is also helpful for detecting SQL Server compact database changes if you're using client side ADO.NET with C# or VB.NET.
A SqlDependency object can be associated with a SqlCommand in order to detect when query results differ from those originally retrieved. You can also assign a delegate to the OnChange event, which will fire when the results change for an associated command.
For more details about SqlDependency, please review the following link.
Detecting Changes with SqlDependency:
http://msdn.microsoft.com/en-us/library/62xk7953.aspx
Thanks,
Lydia Zhang

Similar Messages

  • Inserting data to a . SDF database (SQL Server Compact Edition connection)

    Hi, all.
    I'm working on a project that worked fine while connecting to SQL Server 2008. I used a connection string like this:
    Driver={SQL Server Native Client 10.0};Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
    Now, I've replaced all database connections in my project to work with SQL Server Compact Edition, and my connection string is something like this:
    Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=myDir\myDataBase.sdf; 
    After changing the type of connection, I'm getting an error on "DB Tools Insert Data.vi". This is what I get:
    Error -2147217872 occurred at NI_Database_API.lvlib:Cmd Execute.vi->NI_Database_API.lvlib: DB Tools Insert Data.vi->Main.vi
    Possible reason(s):ADO Error: 0x80040E30 Exception occured in Microsoft SQL Server Compact OLE DB Provider: The given type name was unrecognized. [,,,,,] in NI_Database_API.lvlib:Rec Create - Command.vi->NI_Database_API.lvlib:Cmd Execute.vi->NI_Database_API.lvlib: DB Tools Insert Data.vi->Main.vi
    This is a simplified block diagram (as I said, it worked perfectly while using SQL Server 2008 connection):
    Could you please help me?
    Thanks in advance,
    Francisco

    Hi, Steve. Thanks for your answers.
    I worked around this problem by using directly a SQL query instead of this function (you were right, using DBTools Execute Query VI). But now I'm getting problems with other functions, when inserting data into the DB including NULL values.
    I make a SQL query like this using DBTools Execute Query VI:
    INSERT INTO Table1 (Column1, Column2, Column3, Column4, Column5, Column6) VALUES ('Value1', 'Value2', 'Value3', 'NULL', 'Value5', 'Value6') 
    and get the following error:
    ADO Error: 0x80040E07Exception occured in Microsoft SQL Server Compact OLE DB Provider: A literal value in the command could not be converted to the correct type due to a reason other than data overflow. [,,,,,] in NI_Database_API.lvlib:Conn Execute.vi->INSERT (new) restricción (DBCT).vi->Restricciones a Base de Datos (DBCT).vi->Definir - editar restricciones.vi->Main.vi
    The same SQL query worked perfectly when using the SQL Server 2008 connection, so it's not a database structure issue.
    Could somebody please help me?
    Regards,
    Francisco

  • Can I use Microsoft SQL Server Management Studio version 11.0 to write SQL queries for "SQL Server Compact 4.0 Local Database"

    Hi, Can I use Microsoft SQL Server Management Studio version 11.0 to write SQL queries for "SQL Server Compact 4.0 Local Database" ?
    When I use Connect Object Explorer, the "Connect to Server" dialog box which pops up has only 4 selections in the Server Type Drop Down List. They are Database Engine, Analysis Services, Reporting Services & Integration Services. I have read
    somewhere that there should be a compact database option. but I do not see it.
    What I would like to do is use free form SQL Queries against the tables in "SQL Server Compact 4.0 Local Database" .
    Once I have validated these queries, then I will use them in my Visual Studio 2012 C#, ASP.NET application. I created the Local Database using Visual Studio 2012 for use by my application.
    Thank you for your help..
    diana4

    Hello,
    With SSMS 2005 we have had the Option to work with SQL CE database files, but not with higher Version of SSMS.
    You can use the free SQL CE Toolbax instead; see
    http://sqlcetoolbox.codeplex.com/
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • SQL Server Compact 3.5/4.0 - Client / Server .sdf database file compatibility

    I am considering connecting autonomous Windows Desktop PCs with SQL Server Compact 3.5 SP2 databases via an ASP Website and would like to provide database upload/download capabilities.
    If I use SQL Server Compact 4.0 as the Website database, will the desktop and website files be interchangeable so database files can be uploaded and downloaded without conversion?
    I presume that since the database structure is ado.net in both cases, it will not matter that the ASP website could be using Entity Framework and the Desktop PCs using Linq to SQL as OR/M?
    Thanks for any guidance.
    -BGood

    >>  I can upload .sdf files to the ASP website and have the website convert to 4.0,
    Yes, you can use SqlCeEngine.Upgrade for this
    >> for download purposes I need to develop a REST API 
    No neccesarily, as you could use my scripting libs to script the 4.0 database file to a script, then
    create a new file (alos using my scripting libs) and run the script against the database file (also using my scripting libs) - all on the web server. Remeber to allow 3.5 to run on the web server: http://blogs.msdn.com/b/stevelasker/archive/2006/11/27/sql-server-compact-edition-under-asp-net-and-iis.aspx
    Please mark as answer, if this was it. Visit my SQL Server Compact blog http://erikej.blogspot.com

  • SQL Server Compact 3.5 Merge Replication With SQL Server 2012 - Causing IIS App Pool to Crash

    Hi, I may be the only person in the world doing this but I wanted to give this information to anyone else who may follow this path in the future, and hopefully avoid a headache, or at least a paid support call to Microsoft.
    My original scenario was we had a SQL Server 2008 Server using Merge Replication through and IIS (web server) to several Windows Mobile 6 devices.  This has worked fairly well for a few years.
    Recently we upgraded our SQL server to version 2012 SP 1.  After moving the database over to the new server, and re-setting the merge replication stuff, we couldn't get merge replication to work on the Windows Mobile 6 handheld devices.  The replication
    would appear to start, and then we would get a message saying that the device could not get to the web site.  The message on the handheld device was this:
    "The IIS service is not available."
    After doing some more research, we found that the start of the replication process was causing the Thread Pool that was running the SQLCESA35.dll to crash.  
    The SQLCESALOG.txt file had this information:
    Date Time == SQLCESA Version ==> 3.5.8088.0
    Date Time Hr=80004005 ERR:Couldn't find existing RSCB 1
    After 2 days of trying to figure out the issue on our own, we gave in and called for paid Microsoft support.  They eventually found a known issue where a cumulative update was able to fix the problem.
    We installed the update on the IIS server and everything ran smoothly again.
    FIX: Merge replication fails when you use SQL Server Compact to perform a merge replication that synchronizes changes with a publisher in SQL Server 2012
    http://support.microsoft.com/kb/2845550
    Seth O'Neal

    Hi sonealtx,
    Glad to hear that the issue is resolved. Thanks for your sharing, other community members could benefit from your solution.
    Thanks,
    Lydia Zhang
    Lydia Zhang
    TechNet Community Support

  • How to get Cumulative Update packages for SQL Server Compact v3.5 SP2 for use on a Windows Mobile device

    There are links on the pages for various Cummulative Updates for SQL Compact v3.5 SP2 which look to relate to the desktop version, but are these also available for Windows Mobile devices?  If so, what is the process to get hold of them?
    We are seeing intermittent problems with corrupted databases on devices which are using SQL Compact v3.5 SP2 and have seen that some of the Cumulative Updates do relate to corruption and would like to see if these can help to solve the issue.

    Just select the KB article, at the top of each there is a link to request a hotfix, you will then get a email with a download link. The 8088 and 8109 hotfixes also apply to Windows Mobile.
    http://erikej.blogspot.dk/2010/08/sql-server-compact-35-sp2-downloadable.html
    Please mark as answer, if this was it. Visit my SQL Server Compact blog http://erikej.blogspot.com

  • SQL Server Compact Visual C++

    Is SQL Server Compact a viable platform for future development?  I'm using VS 2010, Native C/C++ and need a good tutorial to walk me through the process of creating a simple db application.  Any suggestions?
    If SQL Compact is not a viable platform, I would appreciate some direction.  My application is very well suited for the 'Compact' single file database with a small number of users.  I'm not interested in .NET.
    Thanks,
    Bob Nichols
    Bob Nichols

    AFAIK, Microsoft stopped SQL Server Compact development and today SQLite is most used on devices.
    It seems that for new application it could be the best choice also portable on other platforms.
    Paolo.
    Paolo Patierno

  • Accessing typed dataset in SQL Server Compact Toolbox in VS 2013

    I am a novice with coding so this could be a very simple answer. I am coding an application in Visual Studio 2013 with VB. I included a Compact SQL Server database using the SQL Server Compact Toolbox add in. The database shows up in my solutions explorer.
    I plan on using a typed dataset for my application but when I try to reference the dataset using this code the intellisense doesn't recognize it.
    Dim newCustomerRow As DHA_dbDataSet.CustomerRow
    My database is named "DHA_db". I am sure there are steps I am missing.
    How do I reference the typed dataset so I can add rows and data to it?
    Thanks in advance.
    Hmm...

    The Toolbox (I am the author of it) does not support Typed DataSets (and neither does VS 2013, I believe). You should use LINQ to SQL instead, and the Toolbox supports code generation for this.
    Please mark as answer, if this was it. Visit my SQL Server Compact blog http://erikej.blogspot.com
    Thank you a ton. I started off with an incorrect assumption about the dataset. Your advice and a google search led me to description of how to add a typed DataSet.
     http://msdn.microsoft.com/en-us/library/04y282hb.aspx 
    I like the Toolbox add in. Thanks for authoring it!
    Hmm...

  • Can TS work with sql server compact or express?

    I'm don't have much experience with the underpinning of database systems.  I know conceptually how they work and can hack my way through sql queries.  Is there something fundamentally different about a Sql Server Compact itnstall versus Sql Server versus Sql Server Express?  Can TS work with any of them with a proper connection string?
    My problem is at our local site a previous employee set us up on Sql Server and wrote a web app (.asp) to do the query for presentation on a web page.  At an offsite location they can't install Sql Server and I'm trying to figure out the best path for them to be able to use the same .asp tool we have.  My gut feeling is the .asp tool is probably set up such that it wouldn't take much to make it work with MySql but because I don't have the luxury of time I'm hoping someone can point me in what they think might be the easiest direction (whether that is sql compact if possible or MySql for them).

    Hi,
    TestStand works with SQL server express. (not sure about SQL server compact).
    Ravi

  • 64-bit application running SQL Server Compact

    Hi
    I have read your article sql-server-compact-4-desktop-app-with...
    I have some questions
    1: The app I have is 32/64-bit (installer will detect and install). Will 64-bit app work with SQLCE40?
    2: The target framework is .NET 4.0. Will this work?
    In the entity project of this application, I have included the following files
    database.sdf
    SQLCE40 (folder)
    - amd64 (folder)
      - Microsoft.VC90.CRT (folder)
        - Microsoft.VC90.CRT.manifest
        - msvcr90.dll
      - sqlceca40.dll
      - sqlcecompact40.dll
      - sqlceer40EN.dll
      - sqlceme40.dll
      - sqlceqp40.dll
      - sqlcese40.dll
    x86 (folder)
      - Microsoft.VC90.CRT (folder)
        - Microsoft.VC90.CRT.manifest
        - msvcr90.dll
      - sqlceca40.dll
      - sqlcecompact40.dll
      - sqlceer40EN.dll
      - sqlceme40.dll
      - sqlceqp40.dll
      - sqlcese40.dll
    Under references I have,
    - System.Data.Entity
    - System.Data.SqlServerCe
    - System.Data.SqlServerCe.Entity
    All these files are taken from
    C:\Program Files\Microsoft SQL Server Compact Edition\v4.0\Private
    Do I strictly need to follow your example where you copy the 32-bit files to the root level?
    app.config
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="System.Data.SqlServerCe.4.0" publicKeyToken="89845dcd8080cc91" />
            <bindingRedirect oldVersion="4.0.0.0-4.0.0.1" newVersion="4.0.0.1" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
          <parameters>
            <parameter value="System.Data.SqlServerCe.4.0" />
          </parameters>
        </defaultConnectionFactory>
        <providers>
          <provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
      </entityFramework>
      <system.data>
        <DbProviderFactories>
          <remove invariant="System.Data.SqlServerCe.4.0" />
          <add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory,                   
    System.Data.SqlServerCe,                    Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
        </DbProviderFactories>
      </system.data>

    >>
    Do I strictly need to follow your example where you copy the 32-bit files to the root level?
    No, you can use x86/AMD64 with Entity Framework, but I suggest you use my NuGet package, see my blog post
    here:
    http://erikej.blogspot.dk/2014/10/entity-framework-6-and-sql-server.html
    You should not have references to: 
     System.Data.Entity and System.Data.SqlServerCe.Entity
    Those are not EF version 6 files. Install the package mentioned above, and you will get the correct references.
    App.config: EF6 configurastion is missing, again install https://www.nuget.org/packages/EntityFramework.SqlServerCompact.PrivateDeployment/
    and things will be right
    Please mark as answer, if this was it. Visit my SQL Server Compact blog http://erikej.blogspot.com

  • ASP Website - Web Config provider problem with EF4 / Sql Server Compact 4.0

    I am setting up a website which will exchange data with remote Windows Desktop applications and am using SQLCE4.0 and EF4.0 to upload and deserialize an entity to the database with the following code:
    Using dc As ContribDataEntities = New ContribDataEntities
       Dim sc As SaleComp = ByteToCSC(comp)
       dc.SaleComps.Add(sc)  <-- Exception occurs here
       dc.SaveChanges()
    End Using
    The exception I get is:
    System.Data.Entity.Core.MetadataException was unhandled by user code
      HResult=-2146232007
      Message=Schema specified is not valid. Errors:
    App_Code.ContribData.ssdl(2,2) : error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlServerCe.4.0'. Make sure the provider is registered in the 'entityFramework' section of the application config file.
    See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
      Source=EntityFramework
    I do not see an entity framework section in my Web.Config, but SqlServerCe.4.0 appears to be there. 
    Any ideas?  Thanks.
    -BGood

    Thanks, ErikEJ. 
    Deleting and re-installing the NuGet packages got around the metadata exception, but I am now having a new problem relating to my DateTime database columns.  This is described in a separate thread:
    http://social.msdn.microsoft.com/Forums/en-US/59befc98-bbd0-4b1a-93a0-f32c94a53b1b/overflow-when-saving-datetime-data-type-in-sql-server-compact-40-with-ef4?forum=sqlce
    -BGood

  • Is SQL Server Compact Dead ?

    Hi have a new project that needs a small footprint,t not networked, database for storage and retrieval  during desktop program operation (no data needs to be stored after program is closed). This is multithreading program that retrieves web pages asynchronously
    puts retrieved data into a temp database and will need to display whatever it has at the moment (even if some requests are not processed yet) in a grid with SQL filtering.  Also the PCs that this will run on will be old and I do not want to install
    a database server on each one...
    So the question is should I use SQL compact or is it currently used by those that already had it in a project ? and no new projects should look at it ?
    Thanks
    Will access from desktop C# winforms program,  using 3.5 maybe 4.x framework.

    I also started to worry about this product and everything I have found on the net so far points to SQL Server CE being deprecated. There has been nothing officially announced by Microsoft with the closest being a response to a MS Connect issue:
    "SQL Server compact edition is in deprecation mode with no new releases planned near future. Last release SQL CE 4.0SP1 (and earlier releases that are still in the support cycle) will continue to be supported through its lifecycle and Microsoft is committed
    to fix any major, production blocking issues found in these releases." (Microsoft Connect)
    The mainstream support for CE 4.0 will end on 2016-07-12 and extended support 2021-07-13 unless they release a new service pack, which I see as doubtful (Microsoft
    Support).
    Support for SSCE has also not been included in Visual Studio 2013 and SQL Server 2014 Management Studio.  Erik's SQL Server Compact Toolbox can be used to add support back to VS2013 (CodePlex).  SQL
    Server CE has even now been removed from the SQL Server website.  It still shows up in search results from Microsoft search (Micorsoft)
    but sometime back in March or April the page was removed (Wayback Machine).
    There are a couple of UserVoice suggestions asking for Microsoft to support and develop SQL Server CE further:
    Support Sql Server Compact in VS2013
    Sql server Compact 5
    So overall even though nothing has been announced it seems pretty clear to me that Microsoft are not continuing development of SQL Server CE and do not want people to use it.  It's dead!

  • Windows 7 and SQL Server Compact 3.5

    Im trying to connect to a SQL Server Compact 3.5 that I have installed on Windows Embedded Compact 7 (Windows CE basically) running on ARM. I got the DB up and running but I cant connect to it.
    Ive read there is no ODBC driver for it. What is the best way to connect to it thru Windows 7?
    Thank you

    You cannot connect to SQL Server Compact remotely, it is an embedded, in-process database.
    If you can establish a ActiveSync/WMDC connection to your devcice, you can connect using SQL Server management Studio Express 2008 R2 (via the ActiveSync connection)
    Please mark as answer, if this was it. Visit my SQL Server Compact blog http://erikej.blogspot.com

  • SQL SERVER 2014 - Project consistency check failed. The following inconsistencies were detected: package.dtsx. has a different ProtectionLevel than the project.

    I am getting the following error when I right click on a package in solution explorer and execute using SQL Server 2014:
    Project consistency check failed. The following inconsistencies were detected: package.dtsx. has a different ProtectionLevel than the project.
    Luckily my solution only has 10 packages.  I have verified and re-verified that everyone is set to dontsavesensitive.
    I have verified and re-verified that the solution has the protection level to dontsavesensitive.
    What on earth is going on here?  I am using windows authentication and have no need for the package to save any sensitive information, nor should there be any.
    Can someone please help me out here?
    The Degenerate Dimension

    Hi MMiligan,
    Just as the error message said, the exactly issue is that the package package.dtsx has a different ProtectionLevel property value than the project.
    So please double check the value of project ProtectionLevel property, like DontSaveSensitive, then make sure all packages in the project use the same ProtectionLevel value.
    If there is still an error message indicated that some packages use a different value, please right-click the indicated package to select View Code, then make sure there is a line like below(the DontSaveSensitive
    protection level corresponds to the value of 0):
    DTS:ProtectionLevel="0"
    The following similar thread is for your reference:
    http://stackoverflow.com/questions/18705161/protection-level-changed-mid-project-now-project-wont-build
    Thanks,
    Katherine Xiong
    If you have any feedback on our support, please click
    here.
    Katherine Xiong
    TechNet Community Support

  • System.Data.SqlServerCe.SqlCeException (0x80004005): Native components of SQL Server Compact engine are not loaded. Please reinstall Microsoft SQL Server Compact.

    Hi
    I have followed http://technet.microsoft.com/en-us/library/ms173298(v=sql.110).aspx to support private deployment for my application in anycpu mode.
    Though its working fine on several XP and Windows 7 , on on particular XP machine , I get this
    System.Data.SqlServerCe.SqlCeException (0x80004005): Native components of SQL Server Compact engine are not loaded. Please reinstall Microsoft SQL Server Compact.
       at System.Data.SqlServerCe.NativeMethods.ThrowIfNativeLibraryNotLoaded()
       at System.Data.SqlServerCe.SqlCeEngine.Dispose(Boolean disposing)
       at System.Data.SqlServerCe.SqlCeEngine.Finalize()
    Can anybody give me directions on this?

    Do you use LINQ to SQL or EF or ADO.NET, is what 
    Yes, I would start by investigating:
    - Do you REALLY need "any CPU", or can you cope with just x86 to make things simpler (See my LINQ to SQL blog post)
    - Is SQL Server Compact installed on this PC, and which build (is it same or different from the one you distribute)
    - Use Process Explorer from sysinternals on the machine to find out where the app tries to load the native libraries from (and fails)
    Please mark as answer, if this was it. Visit my SQL Server Compact blog http://erikej.blogspot.com

Maybe you are looking for

  • I want to call a slideshow in a tabbedpannel.

    I generated a slideshow in Bridge. In my webpage I have a modyfied Spry producttable with instead the original Collapsable panels I have 2 Tabbedpanels. All working fine. When I click in the product table an image shows in the first tabbedpanel. Now

  • Test -Driven Development with the help of Open Script

    Hi Folks, I work on a web application that is based on java and other framework, which is more of an extension of java again. In order to have my test scripts code to be more aligned with developers' code, I want to import the jar file for source cod

  • Where can I find free Christmas stationery for Mac Mail version 6.2?

    Where can I find free Christmas stationery for Mac Mail version 6.2 on my MacBook Pro running OS 10.8.2??? Everything I've tried to download is from 2008-2009 and isn't compatible. ~Patty

  • Photoshop Touch Frozen

    I Was adding another image to my work on photoshop touch, when the program froze. I cannot seem to correct this problem. I am using iPad.

  • Remove the back ground color.

    Good day all! Can anyone help with this little problem? I'm adding a flash button to Dreamweaver. No problem! But!! The background image that the flash button sits upon has a gradient fill. And I want there to be no background color on the flash butt