如何在Config文件中的单个Connectionstring中声明多个Db [英] How Can I Declare Multiple Db In Single Connectionstring In Config File

查看:93
本文介绍了如何在Config文件中的单个Connectionstring中声明多个Db的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以告诉我如何在配置文件中的单个连接字符串中声明多个数据库。

[来自OP的评论]

我使用两个数据库和连接字符串是

can anyone tell that how can i declare multiple db in single connectionstring in config file.
[FROM OP'S COMMENT]
I Use two Data Base and connection string is

<connectionstrings>
  <add name="ora" connectionstring="Your Path" providername="System.Data.Oracleclient" />
  <add name="sql" connectionstring="Your Path" providername="System.Data.sqlclient" />
</connectionstrings></connectionstrings>



[/ FROM OP'S COMMENT]


[/FROM OP'S COMMENT]

推荐答案

一个连接字符串可以将您连接到一个数据库...您可以在适合时使用多个连接字符串...
One connection string can connect you to one database...You can have more than one connection strings to use when fit...


一个连接字符串中的多个数据库不会使编程有意义。您需要为每个数据库声明一个连接字符串。

您必须在web.config文件中执行以下操作:

Multiple databases in one connection string doesn't make programming sense. You will need to declare a connection string for each Database.
You will have to do this like below in your web.config file:
<connectionStrings>
    <add name="DBConnectionString1" connectionString="YourFirstConnectionStringHere" />
    <add name="DBConnectionString2" connectionString="YourSecondConnectionStringHere" />
</connectionStrings>


您没有指定您正在使用的数据库提供程序,因此这里有一个链接,您可以在其中找到基本上任何数据库的连接字符串示例:

连接字符串参考 [ ^ ]



它应该给你一个起点。
You don't specify which database provider you are using, so here is a link where you can find connection string examples to basically any database:
The Connection Strings Reference[^]

It should give you a place to start.


这篇关于如何在Config文件中的单个Connectionstring中声明多个Db的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆