Database db = DatabaseFactory.CreateDatabase();
参考过的资料 http://www.cnblogs.com/hcoona/archive/2009/07/13/1522675.html
配置的该XML.奇怪的是我在另外一台电脑上面可以正常运行.请大侠指点迷津.谢谢各位前来捧场的兄弟姐妹
<dataConfiguration defaultDatabase="WebCardsConnectionString"/>
<connectionStrings>
<add name="DataBaseOwner" connectionString="dbo" providerName=""/>
<add name="WebCardsConnectionString" connectionString="Data Source=10.245.1.155;Database=WebCard;Uid=webcarddbuser;Pwd=1111112345;Pooling=True;Max Pool Size=1000;" providerName="System.Data.SqlClient"/>
<add name="WebCardsLoggingConnectionString" connectionString="Server=10.245.1.155;Database=Logging;Uid=webcarddbuser;Pwd=1111112345;Pooling=True;Max Pool Size=1000;" providerName="System.Data.SqlClient"/>
<add name="WebCardConnectionString1" connectionString="Data Source=10.245.1.155;Initial Catalog=WebCard;Persist Security Info=True;User ID=webcarddbuser;MultipleActiveResultSets=False;Packet Size=4096;Application Name="Microsoft SQL Server Management Studio"" providerName="System.Data.SqlClient"/>
</connectionStrings>
43 个解决方案
#1
提示的内容
The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database, WebCardsConnectionString]) failed: “Microsoft.Practices.EnterpriseLibrary.Data.Database”的类型初始值设定项引发异常。 (Strategy type Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy, index 2)
#2
The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database,
WebCardsConnectionString])
failed: “Microsoft.Practices.EnterpriseLibrary.Data.Database”的类型初始值设定项引发异常。
(Strategy type Microsoft.Practices.EnterpriseLibrary.Common.
Configuration.ObjectBuilder.ConfiguredObjectStrategy, index 2)
WebCardsConnectionString])
failed: “Microsoft.Practices.EnterpriseLibrary.Data.Database”的类型初始值设定项引发异常。
(Strategy type Microsoft.Practices.EnterpriseLibrary.Common.
Configuration.ObjectBuilder.ConfiguredObjectStrategy, index 2)
#3
路过,帮顶up
#4
难道是创建数据库?没用过,友情帮顶!
#5
小帅哥,DataBaseFactory.CreateDataBase()能否贴上来?
====================
中午回来看,上午有课~~~~~
====================
中午回来看,上午有课~~~~~
#6
这个是自带的.
好的.谢谢您
#7
XML
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" />
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging"/>
<!--<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data"/>-->
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
#8
up~!!!!!!!!!!!!
#9
此问题已经解决.
问题是没有Microsoft.Practices.EnterpriseLibrary.Data.database.dll
需要下载安装一个.各种版本.我下载的是for .net framemwork
地址 http://www.microsoft.com/downloads/details.aspx?FamilyId=5A14E870-406B-4F2A-B723-97BA84AE80B5&displaylang=en
这问题我搞了一个通宵.精神不好.一天之际在于晨啊.谢谢大家.
问题是没有Microsoft.Practices.EnterpriseLibrary.Data.database.dll
需要下载安装一个.各种版本.我下载的是for .net framemwork
地址 http://www.microsoft.com/downloads/details.aspx?FamilyId=5A14E870-406B-4F2A-B723-97BA84AE80B5&displaylang=en
这问题我搞了一个通宵.精神不好.一天之际在于晨啊.谢谢大家.
#10
我这有个类似的例子,你看有没有帮助
http://www.mystruggle.com.cn
<configuration>
<appSettings>
<!-- Which provider? -->
<add key="provider" value="System.Data.SqlClient" />
</appSettings>
<!-- Here are the connection strings -->
<connectionStrings>
<add name ="AutoLotSqlProvider" connectionString =
"Data Source=(local)\SQLEXPRESS;
Integrated Security=SSPI;Initial Catalog=AutoLot"/>
<add name ="AutoLotOleDbProvider" connectionString =
"Provider=SQLOLEDB;Data Source=(local)\SQLEXPRESS;
Integrated Security=SSPI;Initial Catalog=AutoLot"/>
</connectionStrings>
</configuration>
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Common;
using System.Configuration;
using System.Data;
namespace DataProviderFactory
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("***** Fun with Data Provider Factories *****\n");
#region Read data from config file & get factory
string dp =
ConfigurationManager.AppSettings["provider"];
string cnStr =
ConfigurationManager.ConnectionStrings["AutoLotSqlProvider"].ConnectionString;
// Get the factory provider.
DbProviderFactory df = DbProviderFactories.GetFactory(dp);
#endregion
#region Get connection / command objects
// Now make connection object.
DbConnection cn = df.CreateConnection();
Console.WriteLine("Your connection object is a: {0}", cn.GetType().FullName);
cn.ConnectionString = cnStr;
cn.Open();
// Make command object.
DbCommand cmd = df.CreateCommand();
Console.WriteLine("Your command object is a: {0}", cmd.GetType().FullName);
cmd.Connection = cn;
cmd.CommandText = "Select * From Inventory";
#endregion
// Print out data with data reader.
// Because we specified CommandBehavior.CloseConnection, we
// don't need to explicitly call Close() on the connection.
DbDataReader dr =
cmd.ExecuteReader(CommandBehavior.CloseConnection);
Console.WriteLine("Your data reader object is a: {0}", dr.GetType().FullName);
Console.WriteLine("\n***** Current Inventory *****");
while (dr.Read())
Console.WriteLine("-> Car #{0} is a {1}.",
dr["CarID"], dr["Make"].ToString().Trim());
dr.Close();
Console.ReadLine();
}
}
}
http://www.mystruggle.com.cn
#11
看看能接到分不
#12
GXGX,结贴给分
#13
学习了
#14
#15
建数据库的时候好像要有表。
不能是个空的。
不能是个空的。
#16
接分帮顶
#17
恭喜自己解决了
#18
这报的错误也太那个了吧。。。。。咳!
我也有次被dll版本搞晕了。郁闷啊。
我也有次被dll版本搞晕了。郁闷啊。
#19
我是来看LZ 头像的 ... 不知道是男的还是女的????
#20
不懂,帮顶
#21
接分来的 学习了..
#22
解决了就只能接分了
#23
换一台电脑不行一般都是运行环境的问题
#24
连不上数据库服务器~~
#25
呵呵···看哈···我也用企業庫···
#26
可能是运行环境的问题
#27
而特天
#28
Database db = DatabaseFactory.CreateDatabase("ConnName");
#29
j f
#30
看来是没分了,不要紧,我是来学习的
#31
···从没碰到过这样的问题 帮顶!
#32
什么也不要说了,给点分,算你狠
#33
都已经搞定了,佩服楼主的钻研精神。
顶
顶
#34
GXGX,给分
#35
说不定有分呢?
#36
上面提示 版本不正确。
#37
路过,帮顶up
#38
看能接到分不?
#39
恩.是的.少个东西没安装
#40
Practices.EnterpriseLibrary
这个版本不一致也会导致出现上面提示的问题
这个版本不一致也会导致出现上面提示的问题
#41
学习一下。
#42
2010.4.29 15.11.10
#43
一天之际在于晨
#1
提示的内容
The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database, WebCardsConnectionString]) failed: “Microsoft.Practices.EnterpriseLibrary.Data.Database”的类型初始值设定项引发异常。 (Strategy type Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy, index 2)
#2
The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database,
WebCardsConnectionString])
failed: “Microsoft.Practices.EnterpriseLibrary.Data.Database”的类型初始值设定项引发异常。
(Strategy type Microsoft.Practices.EnterpriseLibrary.Common.
Configuration.ObjectBuilder.ConfiguredObjectStrategy, index 2)
WebCardsConnectionString])
failed: “Microsoft.Practices.EnterpriseLibrary.Data.Database”的类型初始值设定项引发异常。
(Strategy type Microsoft.Practices.EnterpriseLibrary.Common.
Configuration.ObjectBuilder.ConfiguredObjectStrategy, index 2)
#3
路过,帮顶up
#4
难道是创建数据库?没用过,友情帮顶!
#5
小帅哥,DataBaseFactory.CreateDataBase()能否贴上来?
====================
中午回来看,上午有课~~~~~
====================
中午回来看,上午有课~~~~~
#6
这个是自带的.
好的.谢谢您
#7
XML
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" />
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging"/>
<!--<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data"/>-->
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
#8
up~!!!!!!!!!!!!
#9
此问题已经解决.
问题是没有Microsoft.Practices.EnterpriseLibrary.Data.database.dll
需要下载安装一个.各种版本.我下载的是for .net framemwork
地址 http://www.microsoft.com/downloads/details.aspx?FamilyId=5A14E870-406B-4F2A-B723-97BA84AE80B5&displaylang=en
这问题我搞了一个通宵.精神不好.一天之际在于晨啊.谢谢大家.
问题是没有Microsoft.Practices.EnterpriseLibrary.Data.database.dll
需要下载安装一个.各种版本.我下载的是for .net framemwork
地址 http://www.microsoft.com/downloads/details.aspx?FamilyId=5A14E870-406B-4F2A-B723-97BA84AE80B5&displaylang=en
这问题我搞了一个通宵.精神不好.一天之际在于晨啊.谢谢大家.
#10
我这有个类似的例子,你看有没有帮助
http://www.mystruggle.com.cn
<configuration>
<appSettings>
<!-- Which provider? -->
<add key="provider" value="System.Data.SqlClient" />
</appSettings>
<!-- Here are the connection strings -->
<connectionStrings>
<add name ="AutoLotSqlProvider" connectionString =
"Data Source=(local)\SQLEXPRESS;
Integrated Security=SSPI;Initial Catalog=AutoLot"/>
<add name ="AutoLotOleDbProvider" connectionString =
"Provider=SQLOLEDB;Data Source=(local)\SQLEXPRESS;
Integrated Security=SSPI;Initial Catalog=AutoLot"/>
</connectionStrings>
</configuration>
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Common;
using System.Configuration;
using System.Data;
namespace DataProviderFactory
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("***** Fun with Data Provider Factories *****\n");
#region Read data from config file & get factory
string dp =
ConfigurationManager.AppSettings["provider"];
string cnStr =
ConfigurationManager.ConnectionStrings["AutoLotSqlProvider"].ConnectionString;
// Get the factory provider.
DbProviderFactory df = DbProviderFactories.GetFactory(dp);
#endregion
#region Get connection / command objects
// Now make connection object.
DbConnection cn = df.CreateConnection();
Console.WriteLine("Your connection object is a: {0}", cn.GetType().FullName);
cn.ConnectionString = cnStr;
cn.Open();
// Make command object.
DbCommand cmd = df.CreateCommand();
Console.WriteLine("Your command object is a: {0}", cmd.GetType().FullName);
cmd.Connection = cn;
cmd.CommandText = "Select * From Inventory";
#endregion
// Print out data with data reader.
// Because we specified CommandBehavior.CloseConnection, we
// don't need to explicitly call Close() on the connection.
DbDataReader dr =
cmd.ExecuteReader(CommandBehavior.CloseConnection);
Console.WriteLine("Your data reader object is a: {0}", dr.GetType().FullName);
Console.WriteLine("\n***** Current Inventory *****");
while (dr.Read())
Console.WriteLine("-> Car #{0} is a {1}.",
dr["CarID"], dr["Make"].ToString().Trim());
dr.Close();
Console.ReadLine();
}
}
}
http://www.mystruggle.com.cn
#11
看看能接到分不
#12
GXGX,结贴给分
#13
学习了
#14
#15
建数据库的时候好像要有表。
不能是个空的。
不能是个空的。
#16
接分帮顶
#17
恭喜自己解决了
#18
这报的错误也太那个了吧。。。。。咳!
我也有次被dll版本搞晕了。郁闷啊。
我也有次被dll版本搞晕了。郁闷啊。
#19
我是来看LZ 头像的 ... 不知道是男的还是女的????
#20
不懂,帮顶
#21
接分来的 学习了..
#22
解决了就只能接分了
#23
换一台电脑不行一般都是运行环境的问题
#24
连不上数据库服务器~~
#25
呵呵···看哈···我也用企業庫···
#26
可能是运行环境的问题
#27
而特天
#28
Database db = DatabaseFactory.CreateDatabase("ConnName");
#29
j f
#30
看来是没分了,不要紧,我是来学习的
#31
···从没碰到过这样的问题 帮顶!
#32
什么也不要说了,给点分,算你狠
#33
都已经搞定了,佩服楼主的钻研精神。
顶
顶
#34
GXGX,给分
#35
说不定有分呢?
#36
上面提示 版本不正确。
#37
路过,帮顶up
#38
看能接到分不?
#39
恩.是的.少个东西没安装
#40
Practices.EnterpriseLibrary
这个版本不一致也会导致出现上面提示的问题
这个版本不一致也会导致出现上面提示的问题
#41
学习一下。
#42
2010.4.29 15.11.10
#43
一天之际在于晨