Home » Windows OS

SQL CE 3.5 Connection String

After some stumbling I have my MFC & Managed C++ apps talking just fine.

I've found that for installation reasons, the database is going to be in a read-only location.  At first I thought that would be no problem, but I can't see to get this working. 

Here's my connection string:

m_sFileName = "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source='";
m_sFileName.append( "'D:\\projects\\thdb.sdf';" );
m_sFileName.append( "Mode=Read;");
m_sFileName.append( "Temp File Directory='D:\\';" );

When I do this I get the following error:

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

If I remove the last line and have:
m_sFileName = "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source='";
m_sFileName.append( "'D:\\projects\\thdb.sdf';" );
m_sFileName.append( "Mode=Read;");

I get the following error:
Opening a database as read-only requires a temp path to be specified. [,,,Db name,,]

This leads me to believe there's something wrong with my "Temp File Directory" syntax, but that's how I've found countless samples.

Any assistance would be greatly appreciated.  :)


6 Answers Found


Answer 1

When the database  is on a read-only  location, you must specify a temporary files directory  on a read/write location. This is required for the engine to create temporary files needed when executing queries or doing other bookkeeping.

Answer 2


Thanks for the prompt reply.

Yes, I get that it needs the temp location  for the temp  files, what seems to be eluding me is the syntax  for the temp file  location.

m_sFileName = "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source='"
m_sFileName.append( "'D:\\projects\\thdb.sdf';" ); 
m_sFileName.append( "Mode=Read;"); 
m_sFileName.append( "Temp File Directory='D:\\';" ); 

That gives me the following exception:

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

In this case, I DO have read/write permissions to the D:\ directory, just the thdb.sdf file itself is marked as read-only  and why I am trying to figure out what is wrong  with my "Temp File directory  = 'D:\\';" to cause the exception.

Thanks again.

Answer 3

Is that directory  writable from your process? According to the BOL, the syntax  should be: "ssce: temp  file directory".

Answer 4


I appreciate all your assistance.

I have tried that with the following:

m_sFileName = "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source='"
m_sFileName.append( "D:\\projects\\thdb.sdf';" ); 
m_sFileName.append( "Mode=Read;"); 
m_sFileName.append( "ssce: temp file directory=D:\\Test\\;" ); 

found  the following MSDN page:

and have also tried:
m_sFileName = "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source='"
m_sFileName.append( "D:\\projects\\thdb.sdf';" ); 
m_sFileName.append( "Mode=Read;"); 
m_sFileName.append( "temp path=D:\\Test;" ); 

To triple make sure I can write to the directory  I even added:
FILE* fp = fopen( "D:\\test\\test.txt", "wt" ); 
fclose( fp ); 

I am just stumped as to why it fails.
- The directory exists
- The process can write to the directory

Regardless I get the "Multiple-Step OLE DB operation  generated errors.

This is on Vista, using the 3.5 SP1 framework, with sql  CE 3.5 with the sdf  file marked as read-only.

Thanks again for any advice.


Answer 5


    One issue could be that there is no space between "SSCE:" and "temp" above. The connection  string option is, "SSCE:Temp File Directory". 

    Also, managed  ADO .NET provider of Compact, does not use OLE DB to talk to the database, so, provider keyword should not be set in the connection string. Since you are using managed C++, it could be that the provider keyword is causing related issues. (Could you please try removing it once, for the connection)? I am not very sure of the thing that managed C++ app uses managed provider (ADO .NET) or not, though, but you can try once.


Answer 6


use the same engine of sqlceme35.dll and sqlce that you use




<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure