Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Max Database Size option in ADO causes the Open command to throw

I have a SQLCompact database that I'm trying to access using ADO and C++. However due to the size of the database (300MB, over the default 256MB limit), I have to specify the Max Database Size in the connection string. However doing so causes the .Open(...) function to throw.

The code I'm using:

HRESULT hr = conn.CreateInstance(__uuidof(Connection), NULL);
conn->Open(L"Provider=Microsoft.SQLSERVER.CE.OLEDB.4.0;Data Source=test.sdf;Max Database Size=512", L"", L"",adConnectUnspecified);  

The error:

HR: DB_E_ERRORSOCCURRED

Description: "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done."

Message: "IDispatch error #3105"

Note:

I've tried using the same code, with a smaller database and removing Max Database Size from the connection string and it works as expected. Adding the Max Database Size again causes the problem to reappear, therefore my assumption that it's the one causing the error.

Any thoughts? How can I work with databases over the Provider default size?

like image 343
Omni Avatar asked Oct 30 '22 23:10

Omni


1 Answers

You must use:

Provider= Microsoft.SQLSERVER.CE.OLEDB.4.0;Data Source=test.sdf;ssce:Max Database Size=512

(same applies to password and other SQL Compact specific keywords)

like image 104
ErikEJ Avatar answered Nov 15 '22 03:11

ErikEJ