Part 1 How to retrieve data from different databases in asp net04:33

  • 0
Published on April 24, 2017

Link for all dot net and sql server video tutorial playlists

Link for slides, code samples and text version of the video

Several of our youtube channel subscribers faced this question in a dot net written test.
We have 2 databases
1. USADB – Contains Employees table that stores only US Employees
2. UKDB – Contains Employees table that stores only UK Employees

Implement an asp.net web page that retrieves data from the Employees table both from USADB and UKDB databases.

Add a webform to the project. Drag and drop a GridView control on the webform. Copy and paste the following code in the code-behind file.
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;

namespace Demo
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string USADBCS = ConfigurationManager.ConnectionStrings[“USADB”].ConnectionString;
string UKDBCS = ConfigurationManager.ConnectionStrings[“UKDB”].ConnectionString;
SqlConnection con = new SqlConnection(USADBCS);
SqlDataAdapter da = new SqlDataAdapter(“select * from Employees”, con);

DataSet ds1 = new DataSet();
da.Fill(ds1);

con = new SqlConnection(UKDBCS);
da.SelectCommand.Connection = con;

DataSet ds2 = new DataSet();
da.Fill(ds2);

ds1.Merge(ds2);

Gridview1.DataSource = ds1;
Gridview1.DataBind();
}
}
}

https://cafeadobro.ro/

https://www.stagebox.uk/wp-includes/depo10-bonus10/

depo 25 bonus 25

https://parfumschristianblanc.com/

https://www.barplate.com/wp-includes/js/qris/

https://hotmusic507.org/

Enjoyed this video?
"No Thanks. Please Close This Box!"