Hi all i want to display two unrelated tables in the same datagridview. I m using merge method of datasets but in vain. Any idea Plz

Dare I ask why? Why not use 2 different views next to each other?

Actually I want it to be done throuth DataSets. Actually it is an assignment

I meant dataviews as in table on the form, I was expecting it to be 2 datasets.

Yes LIZr I have 2 DataSets And i Have Merged Them through Merge method of datasets. But Still I m not getting my result
I have Tried following
ds1.Merge(ds2);
dataGridView1.DataSource = ds1.Tables[0].DefaultView;

Any idea plz

K, but merge probably doesnt do what you're expecting.

Im guessing if you had tables such as

Table 1
--------

id    value
1     5
2     10

and

table 2 
--------
uid name
3    john
4    sarah

Im guessing you wanted

id value uid name
1  5       3   john
2  10     4   sarah

yes?

Hi,
try this

ds1.Merge(ds2);
dataGridView1.DataSource = ds1.Tables[0];
dataGridView1.DataBind();

SqlConnection cn = new SqlConnection();

string connstr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Resources\DBMYC.mdf;Integrated Security=True;User Instance=True";
SqlConnection con = new SqlConnection(connstr); //SqlCommand cmd = sqlConnection1.CreateCommand();

SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text; //this has the option of caling a stored procedure
cmd.CommandText = "THE SQL QUERY FOR THE SELECTION FROM TWO TABLES OR MORE";

SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;

//DataSet ds = new DataSet();
//da.Fill(ds, "MYCTAB");

DataTable DT = new DataTable(); //USES DATATABLE INSTEAD OF DATASET
DT.Locale = System.Globalization.CultureInfo.InvariantCulture;
da.Fill(DT);

dataGridView2.DataSource = DT;

THIS WOULD BE OF HELP, IT WORKS.

SUNNY.

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.