I'm quite addicted to Patterns-&-Practices Enterprise.Library.Data module, but I can't get it to access a SQL Server Express Database. I've tried several different .CONFIG files and a unch of different settings and I keep getting:
The local database "XXYYZZ" is not defined in configuration.
I'm using Visual Studio 2005 C# in a WinForms application.
Can Microsoft.Practices.EnterpriseLibrary.Data access SQL Server Express Database?
<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" />
</configSections>
<dataConfiguration defaultDatabase="Connection String" />
<connectionStrings>
<add name="myDb" connectionString="Database=Database;Server=(local)\SQLEXPRESS;AttachDbFilename=C:\myDir\myDBname.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
- and it's use
Database db = DatabaseFactory.CreateDatabase("myDb");
DbCommand dbC = db.GetStoredProcCommand("mySPname");
db.AddInParameter(dbC, "MyParameterName", DbType.Int32, MyIntVal);
DataSet ds = db.ExecuteDataSet(dbC);
Needs this stuff too ...
using System.Data;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Data.Common;
|||As the Elib cannot find the "mydb" entry, it seems that the ELIB is requesting the wrong (in terms of your thinking) .config file. See if you are pointing to the right config file.Jens K. Suessmeyer. http://www.sqlserver2005.de
No comments:
Post a Comment