Hi

Pls help me to slove this problem.I have a method and I pass a dataset to it.and inside the
method it generate another dataset,i want to join dataset1 and dataset2.How do i do tha
below I mention the coidng,it just testing coding.In dataset it contains Retailercode and dataset 2 it also contains RetailerCode,so I want to join both dataset and generate another dataset.

public void Process_Start(DataSet D3)
{
int y = 3;
SqlConnection Con3 = new SqlConnection("Data Source=IT;Initial Catalog=Test;Integrated Security=True");
Con3.Open();
for (int i = 0; i < y;i++)
{
MessageBox.Show(D3.Tables[0].Rows[i]["Shop_Code"].ToString());
string str2 = "Select SalesExecutiveCode,ID from Retailer where RetailerCode='" +"00000"+ D3.Tables[0].Rows[i]["Shop_Code"] + "'";
SqlDataAdapter da4 = new SqlDataAdapter(str2, Con3);
DataSet dt2 = new DataSet();
da4.Fill(dt2,"Test");

Your code is kinda ilogical, as the result of that procedure is the a single ds containing the last shop codes data, but in doing so you could have transferred a lot of data which is already "lost" to the user.

What I think you are trying to do is when changing records in the first dataset repopulate the second, this isnt always the best way, at the same time you could arguably get most of the results in 1 hit using a join on the tables..

HI

Thanks LizR for quick reply.In above method I get from excel and it contains salesexecutivecode,Retailercode,x,y .And In dt2 I populate data from sql sever,so it contains correct salesexecutive code for Retailercode,So I want to get correct Salesexecutive code for retailer and x,y corrdinates for shop.

Thanks

The second query though (unless theres other code elsewhere) just makes for every row in the first grid an identically named object (thus overwriting the previous) and so in the end, you just end up with the last item..

The second query though (unless theres other code elsewhere) just makes for every row in the first grid an identically named object (thus overwriting the previous) and so in the end, you just end up with the last item..

If you did it on changing of the record pointer it would already be linked..

hi

Thanks Lizr for ur idea,that is great idea.

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.