how can we display records in single datagrid using two
datasets in different place?

Answers were Sorted based on User's Feedback



how can we display records in single datagrid using two datasets in different place?..

Answer / ruby

we can do it using merge method of dataset.
but for that bot the tables must have same no. of columns , same fields and their respective datatypes.

also both the data table's name must be same("Table1" of both the datasets)

Sub BindGrid()
Dim myConnection as New SqlConnection (strConn)

Dim DS1 As DataSet
Dim DS1 As DataSet
Dim MyCommand As SqlDataAdapter

MyCommand = new SqlDataAdapter("exec s_get_table1", MyConnection)
DS1 = new DataSet()
MyCommand.Fill(DS1, "Table1")

MyCommand = new SqlDataAdapter("exec s_get_table2", MyConnection)
DS2 = new DataSet()
MyCommand.Fill(DS2, "Table1")
// Then using MERGE function of dataset we can merge both the datasets like

ds1.merge(ds2)
//binding with grid

MyDataGrid.DataSource=DS1.tables(0).DefaultView
MyDataGrid.DataBind()
End Sub

Is This Answer Correct ?    4 Yes 1 No

how can we display records in single datagrid using two datasets in different place?..

Answer / nitin jadav

OracleConnection cn = new OracleConnection("user
id=scott;password=tiger;data source=ganesh1");
OracleDataAdapter da1 = new
OracleDataAdapter("select * from table1", cn);

DataSet ds = new DataSet();
da1.Fill(ds, "temp");

OracleDataAdapter da2 = new
OracleDataAdapter("select * from table2", cn);
DataSet ds1 = new DataSet();
da2.Fill(ds1, "temp");

ds.Merge(ds1);
dataGridView1.DataSource = ds.Tables[0].DefaultView;
label1.Text = ds.Tables[0].Rows.Count.ToString();

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More ASP.NET Interview Questions

what are the advantage in asp.net and what are the question ask for interview in vb.net and asp.net

0 Answers   TCS,


What is smart navigation?

1 Answers  


How do I debug an asp.net application that was not written with visual studio.net and that does not use code-behind?

0 Answers  


How does the browser enable AutoPostBack functionality?

2 Answers  


What is a SESSION and APPLICATION object?

0 Answers  






How does the regular expression validator work? What are two situations when you might want to use one?

2 Answers  


How can we secure the data which is send from client side to server? Like the login id and paasword needs to be authenticated on the server but we cannot send it in plain text into the server.One more thing we are not using the SSL here.

0 Answers   Microsoft,


What is the application pool?

0 Answers  


What are session state modes?

0 Answers  


Why does a user need nothing more than a Web browser to view ASP.NET pages?

1 Answers  


What?s a bubbled event?

1 Answers  


What is server transfer?

0 Answers  


Categories