[英]Can two different types of databases be used in a single SqlDataSource?
I've got a Microsoft SQL Database and a MySQL Database that I need to join and put into a GridView. 我有一个Microsoft SQL数据库和一个MySQL数据库,我需要将它们加入并放入GridView中。
So far I've been successful using ASP and a SqlDataSource like so 到目前为止,我已经成功使用ASP和像这样的SqlDataSource
<asp:SqlDataSource ID="mySqlDataSource" runat="server" ConnectionString="<%$ connectionStrings:cs1 %>" ProviderName="MySql.Data.MySqlClient" SelectCommand="SELECT DashName, DashIP1, SNMP_Name, DoesBackup, DashDevType FROM ConfigBackupDevices"> </asp:SqlDataSource>
How ever I'm not sure how to join in the second database. 但是我不确定如何加入第二个数据库。 Do I need to do this in the code behind or is it possible in asp?
我需要在后面的代码中执行此操作吗,还是可能在ASP中执行?
It is not possible to bind two data sources to one control, but you can use multiple tables in one data source. 不可能将两个数据源绑定到一个控件,但是您可以在一个数据源中使用多个表。 You can also join tables.
您还可以联接表。
It is not possible to bind two databases with one sql datasource. 不可能将两个数据库与一个sql数据源绑定。
The best option is create either DataTable
or DataSet
with desired data using Join to these different databases. 最好的选择是使用Join to这些不同的数据库使用所需的数据创建
DataTable
或DataSet
。 then bind the grid using that DataTable
or DataSet
. 然后使用该
DataTable
或DataSet
绑定网格。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.