I want to fetch data from datareader. i have three tables in
datareader. i want to bind my two table with datagrid, then
i want to fetch a value from my third table. do u have any
idea pls help me. we use dr.nextresult() for multiple tables.



I want to fetch data from datareader. i have three tables in datareader. i want to bind my two tabl..

Answer / Sunidhi Pandey

To achieve this in .NET Framework, you can use the SqlDataReader and DataSet classes. You should first fill your two tables into the DataTable of DataSet and bind them to the DataGridView. To fetch data from the third table, move the reader to the appropriate result set by calling dr.NextResult(). Here's a basic example:nn```csharpnusing System; using System.Data.SqlClient; // ...nstring connectionString = "your connection string"; SqlConnection con = new SqlConnection(connectionString); con.Open(); SqlCommand cmd = new SqlCommand("your query", con); SqlDataReader reader = cmd.ExecuteReader(); DataSet ds = new DataSet(); if (reader.HasRows) {n // Fill first two tables heren}n reader.NextResult(); // Move to the third table's result setn // Get and use the desired valuen reader.Close(); con.Close();```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Dot Net Framework Interview Questions

What is .net framework used for?

1 Answers  


What is razor code?

1 Answers  


What are the components required to create a route in mvc?

1 Answers  


Explain ASP.NET MVC Identity and Security?

1 Answers  


what is use of entitydatasource control?

1 Answers   Microsoft,


If we not suppress finalize method in dispose what will happen?

2 Answers   Kanbay,


What is viewdata?

1 Answers  


I can't be bothered with all this CAS stuff. Can I turn it off

1 Answers  


Briefly describe the roles of clr in .net framework?

1 Answers  


What is the main difference between VS 2005 and VS 2003?

5 Answers   CTS, Satyam,


How to create an alias name for a namespace?

4 Answers   IBM,


How the ‘page lifecycle’ of ASP.Net MVC does works?

1 Answers  


Categories