DevArt.com UniDAC in C++ Builder 2010 to access SQL Server Compact Edition

DevArt makes a number of data access products for Delphi/C++ Builder as well as .NET . I downloaded a trial of the UniDAC Universal Data Access Components for VCL. Unfortunately, the documentation is sparse, to say the least, and C++ builder choked on compiling even a very simple application. Here are a few notes on getting this working to access SQL Server Compact Edition (SQL CE).

Also unfortunately, Microsoft seems to have left a glaring (and even actually hard to believe) defect in its product line by not including any ability to transfer data to or from SQL Server (or any other database) and SQL Server Compact Edition. Thus, I wrote a small utility to transfer my data into SQL CE.

The only code I could find on DevArt’s website for accessing SQL CE was for Delphi rather than for C++ Builder. However, the following works to access SQL CE and read a list of tables:


UniConnection1->SpecificOptions->Values["OLEDBProvider"] = "prCompact";
UniConnection1->Database = "C:\work\VS2010Tests\CreatedDB01.sdf";
UniConnection1->Connect();
TStrings* list = new TStringList();
UniConnection1->GetTableNames(list, true);
ListBox1->Items->Assign(list);

You add a TUniConnection to the form, and then you must set ProviderName in the TUniConnection to ‘SQL Server’ in the property combo box to avoid the EDatabaseError ‘Provider is not defined’.

However, C++ Builder will still fail to link the project with the error [ILINK32 Error] Fatal: Unable to open file ‘SQLSERVERUNIPROVIDER.OBJ’ Apparently the fix for that is to manually edit your .cbproj project file (!), find the <AllPackageLibs>¬†element, and add msprovider140.lib

Now, your project will compile and fill the listbox with the list of tables!

Leave a Reply

Your email address will not be published. Required fields are marked *