简体   繁体   English

可以在单个SqlDataSource中使用两种不同类型的数据库吗?

[英]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这些不同的数据库使用所需的数据创建DataTableDataSet then bind the grid using that DataTable or DataSet . 然后使用该DataTableDataSet绑定网格。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 具有属性的类,可以是两种不同类型之一 - Class with property that can be one of two different types AutoMapper-将两个不同类型的源集合映射到一个目标集合中 - AutoMapper - Map two source collections of different types into a single destination collection 一个Visual Studio解决方案中是否可以有两个不同类型的项目(即,桌面项目和Web项目)? - Can you have two projects of different types (i.e. a desktop project and a web project) in a single visual studio solution? SqlDataSource与ListView一起使用 - SqlDataSource used with ListView 具有不同数据库,实体类型和dbcontext的通用存储库 - Generic Repository with different databases, entity types and dbcontext 具有多个不同类型数据库的存储库模式 - Repository pattern with multiple databases of different types 可以将具有不同泛型类型的对象添加到单个容器中 - Can an object with different generic types be added to a single container 如何在单个事务范围内处理与不同数据库的连接 - How can i handle connections to different databases inside a single transaction scope 将可以为两种不同类型的对象传递给C#中的函数 - Passing an object that can be two different types, to a function in c# 如何处理 json 字段,它可以是两种不同类型之一? - How to handle a json field, which can be one of two different types?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM