none
SQL Server Compact Edition 3.5 C++ Sample

    Question

  • Hi,

     

    I am looking for C++ example using SQL Server Compact Edition 3.5.

    I managed to compile and run the "northwindoledb" c++ example, but still, I am looking for source code to 3.5 (And not 3.1).

     

    Monday, January 14, 2008 7:20 PM

Answers

  • The only big difference between both databases is the IID you use to initialize the data source. Everything else is exactly the same (OLE DB-wise).

     

    I have used this "feature" in my own products to use the same code base to address versions 3.5, 3.1/3.0 and 2.0 with the same code. All I had to do was to unify the header files nad tweak a little bit some of the property names because between 2.0 and 3.x Microsoft changed some of the property values while keeping their names.

    Tuesday, January 15, 2008 9:00 AM

All replies

  • The samples for 3.5 should be available on the "Books OnLine and Samples" download page "soon".

     

    Monday, January 14, 2008 8:02 PM
  • The only big difference between both databases is the IID you use to initialize the data source. Everything else is exactly the same (OLE DB-wise).

     

    I have used this "feature" in my own products to use the same code base to address versions 3.5, 3.1/3.0 and 2.0 with the same code. All I had to do was to unify the header files nad tweak a little bit some of the property names because between 2.0 and 3.x Microsoft changed some of the property values while keeping their names.

    Tuesday, January 15, 2008 9:00 AM
  • Thanks,

     

    I already converted the example to a simple console application supporting 3.5.

    If anyone is interested in a slim implementation you can reply to this thread and I will be happy to suply it.

     

    ~ Ishay

     

    Tuesday, January 15, 2008 4:33 PM
  • Hello-

     

    I'm trying to make the sample run and am having difficulty, sqlce_oledb.h cannot be found.

    :-)

     

    Can you please share your implementation?

    Thank you.

    Saturday, January 19, 2008 4:42 AM
  • sqlce_oledb.h is installed with Visual Studio 2008 (Express). On my test system it is here: C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Include

    Saturday, January 19, 2008 11:49 AM
  • You need to implement the following changes:

     

    1. Change common.h the includes to:

     

    #include "C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Include\sqlce_oledb.h"

    #include "C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Include\sqlce_err.h"

    #include "C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Include\sqlce_sync.h"

     

    2. Change in each place you have CLSID_SQLSERVERCE_3 to CLSID_SQLSERVERCE

     

    That's it.

     

    Hope this helps.

     

    ~ Ishay

    Sunday, January 20, 2008 8:18 AM
  • Hi,

     

    Can you post the sample code. It would be of great help to me.

     

    Thanks & Regards

    Keerti Somasundaram

     

    Tuesday, February 05, 2008 8:41 AM
  • I'm also looking for a C++ sample for SQL Server Compact. There is no sample in SQLCE/Books online: when I install SQLCE Books Online, the "Samples" directory only contains one file: northwind.sdf. Think we should use old ATL stuff with OLE DB

     

    Friday, April 11, 2008 12:59 PM
  •  PierreMF wrote:
    I'm also looking for a C++ sample for SQL Server Compact. There is no sample in SQLCE/Books online: when I install SQLCE Books Online, the "Samples" directory only contains one file: northwind.sdf. Think we should use old ATL stuff with OLE DB

     

     

    When will the sample be available?

    Wednesday, June 18, 2008 10:55 AM
  • Hi,

     

        Someone on this post asked about sample code. I am here, posting sample code to talk to SQL Compact 3.5.

     

        CoCreateInstance(CLSID_SQLSERVERCE, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (void **)&pDSO);
        pDSO->QueryInterface(IID_IDBProperties, (void**)&pIDBProp);
        hr = pIDBProp->SetProperties(cPropSets, pDbPropSet);
        pDSO->QueryInterface(IID_IDBInitialize, (void**)&pIDBInit);

        hr = pIDBInit->Initialize();
        pIDBInit->QueryInterface(IID_IDBCreateSession, (void **) &pIDBCSession);

        pIDBCSession->CreateSession(NULL, IID_IUnknown, (LPUNKNOWN *) &pDBSession);

        pDBSession->QueryInterface(IID_IDBCreateCommand, (void **)&pIDBCreateCommand);

        pIDBCreateCommand->CreateCommand(NULL, IID_IUnknown, (IUnknown **)&pCommand);
        hr = pCommand->QueryInterface(IID_ICommandText, (void **)&pICommandText);
        hr = pICommandText->SetCommandText(DBGUID_DBSQL, (LPCOLESTR)pszSQL);
        hr = pCommand->QueryInterface(IID_ICommand, (void **)&pICommand);
        hr = pICommand->Execute(NULL, IID_NULL, NULL, NULL, NULL);

    and CLSID_SQLSERVERCE for 3.5 is (As you might already know)

     

    GUID CLSID_SQLSERVERCE = {0xf49c559d, 0xe9e5, 0x467c, {0x8c, 0x18, 0x33, 0x26, 0xaa, 0xe4, 0xeb, 0xcc}};

    Thanks

    Udaya

    Wednesday, July 02, 2008 1:57 PM
  • Has anyone tried this through native c++ code. I would like to use a .sdf (sql compact edition db) file through native c++ in linux system.

    Thanks,
    Ganesh Raju
    Monday, August 17, 2009 3:37 PM
  • SQL Compact is not available on Linux
    Erik Ejlskov Jensen, MCTS: WM App, MCITP: SQL 2008 Dev - http://erikej.blogspot.com Please mark as answer, if this was it.
    Tuesday, August 18, 2009 8:04 AM
  • Hi Paulo,

    Is there a way in which I could make this code (in the link http://msdn.microsoft.com/en-us/library/ms172066.aspx) work with the header files

    ssceoledb30.h instead of sqlce_oledb.h
    ssceerr30.h instead of sqlce_err.h

    Problem is, I want to develop a desktop application using SQL CE (Version not important), and I do not have VS 2008 Express installed.
    I have VS 2008 Professional, but the header files (sqlce_oledb.h & sqlce_err.h) are not present in the 'Program Files' directory.

    Thanks!
    SubtleT
    Thursday, October 15, 2009 9:13 AM
  • As with most of MS' software , I try and avoid the MS documentation where possible as it is normally full of irrelevant information and misleading points. I am trying to install 3.5 and getting the usual barrage of meaningless errors.

    Can anyone tell me if 3.5 is stable? I am using VS2008 SP1 and the providers seem to be missing. I have downloaded the install files and run them with no luck. I added SP1 to try and fix - still doesnt work. I can add a .sdf file and then get the error about the missing providers. Ive run the tool msi files - still doesnt work. Ive read the MS documentation which never refers to real world problems so Ive now run out of options.

    Tuesday, January 05, 2010 8:28 PM
  • The sample is now available for download here:

    http://code.msdn.microsoft.com/sqlce


    http://erikej.blogspot.com Erik Ejlskov Jensen - Please mark as answer, if this was it.
    Wednesday, March 03, 2010 7:53 PM
  • Replacing CLSID_SQLSERVERCE_3_5 with CLSID_SQLSERVERCE solved my problems with northwind db sample for SQL CE. I am using SQL CE 4.0. I converted the sample app from mobile platform to windows desktop.

    Except one thing. I could not make insertion work. IRowSetChange::InsertRow just fails.

    Can you give any sql ce example where insertRow works? or codeproject article or any working code?

    • Edited by Atique BD Saturday, December 21, 2013 5:00 AM details
    Wednesday, December 18, 2013 5:51 AM