Can't use Sql ServerCE in Visual Studio Project-Collection of common programming errors


  • msdn Quick Background: I recently upgraded to VS 2008 Pro.  The first install caused a lot of problems on my machine, so I had to wipe it out and reinstall.  Now everything works okay (except for below), though sometimes there are unusually long pauses for certain functions.  I originally posted on VS Install forum but I think this might be a better place.

    I cannot add or work with Sql Server CE databases in VS 08 (full Sql server databases appear to be ok so far).  I can add a local database to my project – sometimes it will give this error after naming it:  “An error occured when retrieving the information from the database:  Exception has been thrown by the target of an invocation.”  But then it still shows up in Server Explorer.   If I attempt to view the database from there (such as refresh or edit tables) I again always get the msgbox error “Failed to retrieve data for this request.”  I wonder if this is an installation issue as I’m not sure what else it could be.

  • 15 Answers


  • msdn1

  • msdn2 Hi, Please let me know you are working with VS 2008 or VS 2008 Sp1?Please try to repair 1. VS (itself)2. Install\Repair SQL Compact tools from WCU\SSCE 3. Install\Repair SQL Compact Runtime from WCU\SSCE4. Reinstall VS Sp1 patch is you are uinsg VS2008 Sp1. Please let me know if you still have any issues. Thanks & Regards

    Devesh Anand


  • msdn3

    Following the link of Imram (and other posts) I attempted to install Tools and Runtime from WCU/SSCE.  However, I got the error message “A later version is already installed.”  I had versions 5692 in accordance with Anand’s advice. 

    So, I removed SSCE Tools and Runtime, then reinstalled them from WCU/SSCE.  Now everything works.  However, my versions for these are now 5386, not 5692, even though I have VS08 SP1.

    So now everything is working, even though the version numbers are not as suggested above.  I’m not sure what to make of that.


  • msdn4 “Can you please update us on whether you are able to use Server Explorer to create and edit SQL CE database directly.”I can add SQLCompact database to my project using the ‘Add item’ from the VS menu (with error message in original post).  However, if I go to Server Explorer and do ‘Create Connection’ then choose ‘SQL Server Compact 3.5’, after entering the new database name and pressing ‘Create’, the menu just disappears and nothing happens, not does the database show up in Server Explorer.  From online guides I think the process is supposed to continue with another menu.

    When I try to add a table with Server Explorer, after entering in table and column names and clicking ‘OK’, I get the usual message of “Failed to retrieve data for this request.”  However, the table must have been created, because if I go back and try to add the table again with the same name, I get a ‘table name already exists’ error.  But, no tables ever appear in Server Explorer, just the “failed to retrieve data for this request” when expanding table folder. 

    Again, for normal SQL Server databases on our network, I can see all the tables fine with no error messages.  I will continue to look at the repair options you guys have given.


  • msdn5

    Imram, I downloaded from your link and it said I have a later version on my machine.  I have SQL Compact 3.5 SP1.  I tried to repair with that but the problem remains.  I am trying a complete repair of VS now.


  • msdn6 Thanks for the reply.  I am confused on a few points.  This is what is listed in Add/Remove:1.  Microsoft SQL Server Compact 3.5 for Devices ENU2.  Microsoft SQL Server Compact 3.5 SP1 Design Tools English3.  Microsoft SQL Server Compact 3.5 SP1 EnglishIs #2 what you mean when saying SQL Compact Tools?  Or do you mean Sequel Server CE Server Tools?  Also, I bought VS08 recently and it installs VS SP1 automatically, so I do not think I can repair VS and VS SP1 separately. 

  • msdn7 I am 98% sure that I did default installation; I do not remember changing any of the default settings, nor would I have any reason to do so.I have both versions you mentioned above:  Compact 3.5 for Devices 5386 and the 5962 SP1 installed.I have now run repair for all VS, as well as repair for just SQL Server Compact 3.5 multiple times.    So, I have 3.5 for Devices, but apparently not 3.5 for Desktop for some reason.  You guys have mentioned both and I’m not sure of their relationship.  Should I have both Desktop and Devices, or just one, or does it make a difference?  Should I try to find and download the Desktop?

    If all else fails, I will probably reimage my cpu and start over, but of course hopefully it does not come to that.


  • msdn8

    Sorry to jump in on this thread but I am getting a very similar issue.  I can progmatically create SQLCE databases fine but when it comes to trying to add them as a data source I get the dreaded “Exception has been thrown by the target of an invocation” on the ‘Choose Your Database Objects’ page of the Data Source Configuration Wizard.  This also happens on the Northwind sample database.  I have googled for hours with no luck so am at a loss :(Is this the same issue perhaps?As Tekito I have done a full repair of VS2008 Pro and reinstalled Compact 3.5 (I am only running it as a desktop client, no mobile devices).

    Running Vista sp1 32bit


  • msdn9

    1. “Microsoft SQL Server Compact 3.5 for Devices ENU” is Compact 3.5 for devices (version 5386 is RTM, version 5692 is SP1)2. “Microsoft SQL Server Compact 3.5 SP1 Design Tools English” is Compact 3.5 Tools (version 5386 is RTM, version 5692 is SP1)3. “Microsoft SQL Server Compact 3.5 SP1 English” is Compact 3.5 for Desktop  (version 5386 is RTM, version 5692 is SP1)

    1. Compact 3.5 for devices contains Runtime cabs for the Devices programming (only required to program against devices)

    2. Compact 3.5 tools is for integration of SQL Compact runtime with VS (required)

    3. Compact 3.5 for desktop is runtime for desktop (required ) 

    IF YOU ARE USING VS08SP1 NEED TO HAVE SP1 VERSION OF #2 AND #3 (5692)

    Thanks & regards,

    Devesh Anand


  • msdn10

  • msdn11

    Many thanks, re-installing SP1 fixed the glitch for me..


  • msdn12 Tekito,Has your problem got resolved. Thanks & Regards

    Devesh Anand


  • msdn13

    Following the link of Imram (and other posts) I attempted to install Tools and Runtime from WCU/SSCE.  However, I got the error message “A later version is already installed.”  I had versions 5692 in accordance with Anand’s advice. 

    So, I removed SSCE Tools and Runtime, then reinstalled them from WCU/SSCE.  Now everything works.  However, my versions for these are now 5386, not 5692, even though I have VS08 SP1.

    So now everything is working, even though the version numbers are not as suggested above.  I’m not sure what to make of that.


  • msdn14

    My problem appears resolved.  I just thought it might be worth noting that it was resolved with versions 5386 instead of 5692. 


  • msdn15 Tekito & Deano, I find this strange that Compact SP1 3.5.5692 is not working with VS08 SP1. Did you try reinstallating VS08-SP1?I wanted to connect with you to discuss this in more deatils. Please send me a test mail:  devesha{at}microsoft.comI would like to resolve your problem (using Compact 3.5 SP1). Thanks & Regards,

    Devesh Anand