views:

243

answers:

1

I am using OleDB to connect to an excel file using this connection string

@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 12.0 Xml;HDR=YES"""

But when I do this (which is inside a TransactionScope())

using (OleDbConnection conn = new OleDbConnection(connectionString))
{
    conn.Open();
    ...
}

I get the following error

The ITransactionLocal interface is not supported by the 'Microsoft.ACE.OLEDB.12.0' provider. Local transactions are unavailable with the current provider.

How do I make the OleDbConnection not try to enlist in the distributed transaction? The SqlConnection class has a ConnectionString property called 'Enlist', but I can't find an equivalent configuration or method for OleDB.

+1  A: 

In your connection string add the following code : ";OLE DB Services=-4;"

Reza Ahang
Thanks, that worked!
jayrdub