Connect to SQL Server Compact Edition (.sdf) from an MFC Application

I am creating an MFC application in Visual Studio 2008 that classifies textures, and I need some kind of lightweight database to store characteristics (just a few doubles and lines), which can be:

  • It is performed using the application on different computers.
  • Be able to fulfill requests for it from the application (search, updates, inserts, etc.)

I am currently studying SQL Server Compact Edition because it was very easy to create from Visual Studio (I also need only one table). But it's hard for me to find and update a database with C ++.

This is what I found on MSDN regarding C ++ and SQLCE:

public: void createSqlCeConnection(){ SqlCeConnection* myConnection = new SqlCeConnection(); myConnection->ConnectionString = "DataSource = blabla.sdf"; MessageBox::Show(String::Format( S"Connection State: {0}", __box(myConnection->State))); } 

Unfortunately, my experience with .NET applications is quite limited.

I hope you, bright minds, could tell me if I am on the right track, and what links and inclusions should I add for this to work with C ++ MFC projects.

+4
source share
1 answer

For C ++ applications, you will want to use the OLE DB provider for SQL CE . For example, look here for a snippet of code when initializing a session (you may need to explicitly click the C ++ tab in the "Examples" section).

+2
source

Source: https://habr.com/ru/post/952095/


All Articles