views:

12

answers:

1

I'm trying to run my asp.net application on a windows machine (XP SP3, Vista, 7) which has only Microsoft.ACE.OLEDB.12.0 as the database engine installed and need to connect to the standard aspnetdb.mdf user database.

Does any one know it is possible to use a connection string that works with mdf files in such a condition? I used connection strings like this but no success yet:

connectionString = "provider=Microsoft.ACE.OLEDB.12.0;Data Source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true";

Thanks

A: 

Try one like this:

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\aspnetdb.accdb;Persist Security Info=False;

For more connectionstrings, go to http://www.connectionstrings.com/access-2007

EDIT: It's not possible to connect to a Sql Server database using OleDB. Install SQL Server (Express) instead.

ZippyV
Thanks ZippyV, but when I attemp to open the connection I get the following error:Unrecognized database format 'C:\Users\Mehrdad\Documents\Visual Studio 2010\Projects\radsoft\radsoft\App_Data\ASPNETDB.MDF'.The code in C# is:String connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|aspnetdb.mdf;Persist Security Info=False;";OleDbConnection Connection = new OleDbConnection(connectionString);Connection.Open();
Mehrdad
I doubt the possibility of connecting to an mdf database using this OLEDB provider!
Mehrdad
I thought you were using an Access database. Now I see that an mdf file is from sql server. It's not possible to use the OLEDB provider to connect to a sql server database.Just install SQL Server Express and your problem will be solved.
ZippyV