Part 1 How to retrieve data from different databases in asp net

preview_player
Показать описание
If you are a foodie like me, I am sure you will enjoy the recipes on my friend's YouTube channel. If you find them useful, please subscribe and share to support her. She's really good at what she does.

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

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();
}
}
}
Рекомендации по теме
Комментарии
Автор

Venkat, words can't explain how much of a blessing you are to the .NET community. I sometimes call you the .NET PROPHET ... lol. You explain the most complex subjects like singing a soft kindergarten lullaby. God bless you sir!

folorunso
Автор

Hi Venkat,  I am very big Fan of you.. Daily i used to watch your tutorials, They are  very helpful to us, You are making proud to every Indian, You are putting this much of effort with out expecting any money from us.. Hats up brother, Keep going like this.. Post more and more videos.. THANK U..

ZoyaArru
Автор

Mr. Venkat, you are very special! Thank you for sharing your knowledge in a way we all understand!!

fr-or-v
Автор

Dear kudvenkat sir .
This side neeraj upadhyay as a software developer i love your channel and your's vedio,
sir if possible to upload pattern printing and algorithm tutorial in your's channel pls be uploaded that

neerajupadhyay
Автор

Mr. Venkat, a very big kudos to you, you have indeed contributed a lot to my understanding on asp.net. May Allah keep increasing you in knowledge.

olaiyahabeeb
Автор

I have watched your videos quite a while now, and you are the best on youtube!!!

saithibaw
Автор

an interview question I faced was to count the occurrences of a single character in a string. Eg count all the "P" in "Polly put the kettle on polly put the kettle on we all have tea"

MrIrrepressible
Автор

I haven't subscribe any programming channel till now.But now I can't control myself to subscribe u dude.Try More Harder we will support more and more....Thanks.😊

mgpyaephyoswe
Автор

Thank you Venkat Sir for all these video's.
They are very helpful for all the students.
Sir i request you to please share video related to AJAX.
Thanks & Regards

raghsasr
Автор

thank you for all your tutorial series which are so good

behnamamiri
Автор

Hello! sir Your all videos are too good and very help full for me and others. I am a student.
Sir, I wnt to know diff between varchar and nvarchar and which one would be better to use with an example.

inzimamansari
Автор

Venkat, Great video ... Its helped me lot ... If possible please upload the video " How can we authenticate login  credential with different portal DB, ( I am moving one portal to another portal  based on my one portal credential same as another portal but need to check with other portal DB having same credential  )

Please suggest me .. I need to work upon same kind of story ..

Krranganathakr
Автор

Hi venkat, u r doing amazing job...
I really need ur help..
How can we retrieve newly added rows from a table.
Suppose table with 100 rows is there am adding 10 rows to that table now i want to retrieve only that 10 row.. And afterwards if its being added by 20 new rows so only that 20 rows should be display..
How to do this.. Please help me with that..!!

anamikapatel
Автор

hi sir venkat.by follwing your videos itself iam clearing intrview rounds.tanks for tthat.SIR PLS TRY TO UPLOAD VIDEOS ON RESTFUL WCF SERVICES, WEB API, MEMBERSHIP CONCEPTS

seshubabu
Автор

You are Nic Tutorial Sir Really Helpful....

kirandhere
Автор

Hi Venkat.. I have watched many of your videos and learned a lot in .NET, MVC.  I had an interview recently and in that Interviewer asked me to create an array with Distinct numbers from an Array[100] where the numbers are duplicated. Could you tell me how to do that?

rpfmzot
Автор

I need to retrieve data from sql, pass it to a hidden aspx page and then call the data using java script. The data is a list of longitude and latitude coordinates for building locations and the java script will push the data to google maps api to add location markers of the buildings to the map. Ive watched the first 2 videos of this series and they look great. Will they help me to execute my task?

ukdc-acdctribute
Автор

hi Venkat, thanks for great tutorial, can you please help with this scenario - if I have some columns coming from one database and some corresponding information coming from other database and want to merge these two data sets based on the common columns

aadityendra
Автор

Venkat, I see that you have created the 2 tables in a way that the ID's are sequential. Now, what happens if the ID's in the tables start with identity seeded?

Also, I assume the same logic would hold for multiple DS, except for changes in the connection string. Am I making the right assumption?

Thanks,

asterixgaul
Автор

Your videos are very, very helpful. I think, they are the best!!!! Have you ever think to do ‘Tree Traversal’ video? It would be very good. 

nelyapastarnak
join shbcf.ru