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.
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 |
What is .net framework used for?
What is razor code?
What are the components required to create a route in mvc?
Explain ASP.NET MVC Identity and Security?
what is use of entitydatasource control?
If we not suppress finalize method in dispose what will happen?
What is viewdata?
I can't be bothered with all this CAS stuff. Can I turn it off
Briefly describe the roles of clr in .net framework?
What is the main difference between VS 2005 and VS 2003?
How to create an alias name for a namespace?
How the ‘page lifecycle’ of ASP.Net MVC does works?