用Enterprise Library 5,如何连接AS/400 DB2?

miaomiaoga 2011-10-25 02:31:00
我用了EL5,然后连接AS/400,错误提示是:老是失败。是不是我的Web.config文件写得不对呢?

<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>
<dataConfiguration defaultDatabase="MM">
</dataConfiguration>
<connectionStrings>
<add name="MM"
providerName="IBM.Data.DB2"
connectionString="database=asiadb;uid=xxxx;pwd=yyyy;Persist Security Info=false;"/>
<add name="asiadb_400"
providerName="IBMDA400.DataSource.1"
connectionString="Provider=IBMDA400.DataSource.1;Persist Security Info=False;User ID=xxxx;PASSWORD=yyyy;Data Source=asiadb;"/>
</connectionStrings>

错误提示是:

The type Database cannot be constructed. You must configure the container to supply this value.

Line 50: SbOC.Append("WHERE 1=1 ");
Line 51:
Line 52: Database db = DatabaseFactory.CreateDatabase();
Line 53:

但如果我采下面这种传统的sqladaptor+sqlcommand连接是成功的.
<appSettings>
<add key="Connection_Asia_Odbc" value="Driver={Client Access ODBC Driver (32-bit)};System=asiadb;Uid=xxxx;Pwd=yyyy;DBQ=MAPSPLIBPR,MAPSFLIBPR,INFLIBPRH1,INPLIBPRH1,MAPSCOMF,MAPSUTIL,MAPSQGPL,QTEMP,ACCTCOMM,ACCTDATA,INFLIBPRA,INPLIBPRA,UTILITIES,QGPL;"/>
</appSettings>
...全文
359 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
keepfool 2011-10-26
  • 打赏
  • 举报
回复
直接设置ConnectionString不行吗?ProviderName改一下?
miaomiaoga 2011-10-26
  • 打赏
  • 举报
回复
编辑器里是没有AS400 UDB和IBM DB2的配置的。

所以才要自己来写那一段。但试了还是不行。
miaomiaoga 2011-10-26
  • 打赏
  • 举报
回复
试了一下,成功了! 谢谢大家!

<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>
<dataConfiguration defaultDatabase="Asiadb_OdbcDb">
<providerMappings>
</providerMappings>
</dataConfiguration>
<connectionStrings>
<add name="Asiadb_OdbcDb"
providerName="System.Data.Odbc"
connectionString="Driver={Client Access ODBC Driver (32-bit)};System=asiadb;Uid=XXXX;Pwd=YYYY;DBQ=MAPSPLIBPR,MAPSFLIBPR,INFLIBPRH1,INPLIBPRH1,MAPSCOMF,MAPSUTIL,MAPSQGPL,QTEMP,ACCTCOMM,ACCTDATA,INFLIBPRA,INPLIBPRA,UTILITIES,QGPL;"/>
</connectionStrings>
miaomiaoga 2011-10-26
  • 打赏
  • 举报
回复
ProviderName改过很多了,都不行,

但如果我采下面这种传统的sqladaptor+sqlcommand连接是成功的.
<appSettings>
<add key="Connection_Asia_Odbc" value="Driver={Client Access ODBC Driver (32-bit)};System=asiadb;Uid=xxxx;Pwd=yyyy;DBQ=MAPSPLIBPR,MAPSFLIBPR,INFLIBPRH1,INPLIBPRH1,MAPSCOMF,MAPSUTIL,MAPSQGPL,QTEMP,ACCTCOMM,ACCTDATA,INFLIBPRA,INPLIBPRA,UTILITIES,QGPL;"/>
</appSettings>

我的目的就是想用Enterprise Library 5去访问,保持整个项目的编程规范.:(
keepfool 2011-10-25
  • 打赏
  • 举报
回复
EntLib自带配置文件编辑工具,你用这个工具编辑DataBase节点试试。
Universal Data Access Components (UniDAC) is a powerful library of nonvisual cross-database data access components for Delphi, Delphi for .NET, C++Builder, and Free Pascal. The UniDAC library is designed to help programmers develop faster and cleaner cross-database applications. UniDAC is a complete replacement for standard database connectivity solutions and presents an efficient native alternative to the Borland Database Engine and dbExpress for access to Oracle, SQL Server, MySQL, InterBase, Firebird, SQLite, DB2, Microsoft Access, Advantage Database Server, Adaptive Server Enterprise, and other databases (using ODBC provider). UniDAC is based on the well-known Data Access Components from Devart such as ODAC, SDAC, MyDAC, IBDAC, and PgDAC. We have joined the experience of long-term successful development into one great product which provides unified access to popular databases such as Oracle, Microsoft SQL Server, MySQL, InterBase, Firebird, SQLite, DB2, Microsoft Access, Advantage Database Server, Adaptive Server Enterprise, and other databases (using ODBC provider). The UniDAC library is actively developed and supported by Devart Team. If you have questions about UniDAC, email the developers at unidac@devart.com or visit UniDAC online at http://www.devart.com/unidac/. Advantages of UniDAC Technology UniDAC is very convenient in setup and usage. It provides transparent server-independent interface for working with different databases. Selected database provider ensures the best way to perform operations on the server. Universal Data Access UniDAC provides transparent server-independent interfaces for working with different databases, and lets you change the client engine for specific server type just by changing single connection option. It means that you can easily switch between database servers in your cross-database UniDAC-based application. Server-Aware Providers UniDAC chooses the best way specific to the server to perform most operations. Every UniDAC data provider uses server-specific native connectivity. All operations with data are performed by providers automatically considering peculiarities of the selected database server. Optimized Code The goal of UniDAC is to enable developers to write efficient and flexible database applications. The UniDAC library is implemented using advanced data access algorithms and optimization techniques. Classes and components undergo comprehensive performance tests and are designed to help you write high-performance, lightweight data access layers. Compatibility with Other Connectivity Methods The UniDAC interface retains compatibility with standard VCL data access components like BDE. Existing BDE-based applications can be easily migrated to UniDAC and enhanced to take advantage of server-specific features. Development and Support UniDAC is a cross-database connectivity solution that has been actively developed and supported. UniDAC comes with full documentation, demo projects, and fast (usually within one business day) technical support by the UniDAC development team. Find out more about how to get help or submit feedback and suggestions to the UniDAC development team in the Getting Support topic. A description of the UniDAC components is provided in the Component List.

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧