在Webiste中使用第二个数据库

编程入门 行业动态 更新时间:2024-10-28 11:23:47
本文介绍了在Webiste中使用第二个数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

亲爱的所有人, 我创建了一个网站,现在需要进一步处理,我想从另一个我未连接或未使用连接字符串的数据库中应用选择查询. 因此,我只想从第二个数据库中如何在我网站的另一页中应用选择查询. 如果可能的话,请告诉我怎么做? 谢谢和问候... Mitesh

Dear all, i make a website and now further process i want to apply select query from the another database which i have not connect or not use connection string. so, i just want to how to Apply select query in another page of my website from the second database. if it is possible , so please tell me how ? Thanks and Regards... Mitesh

推荐答案

在web.config中,您可以添加多个连接字符串,如下所示: In web.config, you can add multiple connection strings as follows: <connectionStrings> <add name="connStr1" connectionString="server=localhost;database=yourDb;uid=yourUser;password=password;" /> <add name="connStr2" connectionString="server=localhost;database=yourDb;uid=yourUser;password=password;" /> </connectionStrings>

要阅读,请使用以下代码:

For reading, use the following code:

string connStr1 = ConfigurationManager.ConnectionStrings["connStr1"].ConnectionString; string connStr2 = ConfigurationManager.ConnectionStrings["connStr2"].ConnectionString;

只需尝试以下查询.假设您的第一个数据库名为Database1,第二个数据库名为Database2 Just try the following query. Assume your first database is named as Database1 and second one is named as Database2 Select a.*,b.* from Database1.Table1 as a, Database2.Table1 as b

希望这会有所帮助 问候 塞巴斯蒂安(Sebastian)

Hope this helps Regards Sebastian

您也可以使用 WEB SERVICE 检查此文章 您的第一个C#Web服务 [ ^ ] 最好的问候 米特瓦里(M.Mitwalli) Hi , You can also use WEB SERVICE Check this Article Your first C# Web Service[^] Best Regards M.Mitwalli

更多推荐

在Webiste中使用第二个数据库

本文发布于:2023-10-22 20:04:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1518566.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:第二个   数据库   Webiste

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!