connection string problems

Aug 28, 2015 at 2:39 AM
Hello,

I have problems connecting to local mdf database. I'm using VS2012 Express. Below is connection string:
<add name="CompanyDataConnectionString"
  connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\MyDatabase.mdf;Integrated Security=True;Connect Timeout=30;Provider=SQLOLEDB"
  providerName="System.Data.SqlClient" />
And here is the error:

System.Data.OleDb.OleDbException was unhandled by user code
Message=No error message available, result code: DB_E_ERRORSOCCURRED(0x80040E21).
Source=System.Data
ErrorCode=-2147217887
StackTrace:
   at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
   at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.OleDb.OleDbConnection.Open()
   at Geekees.Common.Controls.Demo.ASTreeViewDemo6.bsearch_OnClick(Object sender, EventArgs e) in d:\bogomil\local\2\Samples\Geekees.Common.Controls.Demo\ASTreeViewDemo6.aspx.cs:line 55
   at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:

I'm using SQL Server 2012, windows authentication. Or you can try to show me how to connect directly to SQL Server database. Any solution is welcome.

Thanks
Aug 28, 2015 at 6:54 AM
Solved
<add name="DBInfoCityConnectionString1" connectionString="Provider=SQLNCLI11;Server=.\SQLExpress;AttachDbFilename=|DataDirectory|MyDatabase.mdf;Trusted_Connection=Yes;" />