本文介绍了在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中使用第二个数据库
发布评论