Thursday, January 17, 2019

How to Load Resultset data to datatable in c#

In this article i have explain how to load data reader result set to data table. We have a result set that are retrieve from database now i want to load these result set to data table. for doing this we are used to following code in c#.

                string sql="select * from tbldataTable";
                SqlCommand cmd = new SqlCommand(sql,conn);
                SqlDataReader rdr = cmd.ExecuteReader();
                DataTable dt = new DataTable();
                if (rdr.HasRows)
                    dt.Load(rdr);

The above code are convert the result set to data table .

No comments:

Post a Comment

Featured Post

What is JavaScript? What is the role of JavaScript engine?

  The JavaScript is a Programming language that is used for converting static web pages to interactive and dynamic web pages. A JavaScript e...