Search code examples
windows-cesql-server-ce-3.5

Windows CE 6.0 SQL Server Compact 3.5


I would like to programatically create a database under Windows CE 6.0. It should use SQL Server Compact 3.5.

The problem is, that I don't know how to start here. I cannot find proper examples of creating and managing SQL Server database under Windows CE.

Does anyone have any example of that? Or a tip what API should I use?

Thanks in advance!

P.S. It must be made in native code C/C++!


Solution

  • In order to use SQL Server Compact from C++ you will need to use the SQLCE OLEDB provider. You can start using it by including the appropiate header files and creating an instance of the corresponding COM class (sample code from MSDN):

    //Include SLQ CE header files
    #include <sqlce_oledb.h>
    #include <sqlce_err.h  >
    (...)
    //create an instance of the SQLCE OLEDB provider
    hr = CoCreateInstance(CLSID_SQLSERVERCE, 0, CLSCTX_INPROC_SERVER, IID_IDBProperties, (void**) &pIDBProperties);
    

    For more details on the rest of the process, I think the following links will be a good start point:

    How to: Create a Database by Using OLE DB (Programmatically)
    Creating Databases with OLE DB
    Building Native Applications (SQL Server Compact)
    OLE DB Provider Reference (SQL Server Compact)