I've got a Microsoft SQL Database and a MySQL Database that I need to join and put into a GridView.
So far I've been successful using ASP and a SqlDataSource like so
<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?
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.
The best option is create either DataTable
or DataSet
with desired data using Join to these different databases. then bind the grid using that DataTable
or DataSet
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.