How can I query a MS SQL Compact Server 3.5 database in C++ not using the OLE DB API?

前端 未结 3 718
离开以前
离开以前 2021-01-21 17:43

I have the dlls and the include files of MS SQL Compact Server 3.5. How can I use it without OLE DB? I just want to load the dlls and invoke the necessary methods myself, no COM

3条回答
  •  悲&欢浪女
    2021-01-21 18:18

    For those who are interested in how the issue is resolved.

    One does not have to install SqlCE in order to use its COM API.

    Here are the steps:

    1. Make sure you have the right dlls.

      For SqlCE 3.0 the dlls are:

      • sqlceca30.dll
      • sqlcecompact30.dll
      • sqlceer30xx.dll
      • sqlceme30.dll
      • sqlceoledb30.dll
      • sqlceqp30.dll
      • sqlcese30.dll

      for SqlCE 3.5:

      • sqlceca35.dll
      • sqlcecompact35.dll
      • sqlceer35EN.dll
      • sqlceme35.dll
      • sqlceoledb35.dll
      • sqlceqp35.dll
      • sqlcese35.dll

      and for SqlCE 4.0:

      • sqlceca40.dll
      • sqlcecompact40.dll
      • sqlceer40EN.dll
      • sqlceme40.dll
      • sqlceoledb40.dll
      • sqlceqp40.dll
      • sqlcese40.dll

      You may also need the .h file for the definitions of the respective COM classes. I have these:

      • sqlce_err.h
      • sqlce_oledb.h
      • sqlce_sync.h
    2. Given an sdf Sql CE database file you have to determine which version it belongs to. Google for it, basically you need to read the first 16 bytes of the file, find the magic number and it determines the version.

    3. Knowing the Sql CE version, locate the directory containing the respective Sql CE dlls (see above).
    4. Call ::LoadLibrary win32 API for the sqlceoledbNN.dll, where NN is 30, 35 or 40. It depends on other dlls, so they must be near it.
    5. Call ::GetProcAddress win32 API to get the address of the exported DllGetClassObject function.
    6. Having at hand the pointer to the DllGetClassObject you are ready to exercise the COM API provided by the Sql CE.

    "Enjoy"

提交回复
热议问题