For training related to .net,OOPS,design patterns, MVC,WCF and .net fundamentals
contact at sukeshmarla@gmail.com or Click Here

Click here for my training feedbacks

Followers

Follow Us



Share your Interview questions here


For software development queries contact SukeshMarla@Gmail.com

Follow by Email

Learn everything about JSON in a day

15 May 2011

SqlDataReader To DataTable

class ClsDataReaderToDataTable
{
    static void Main(string[] args)
    {
        string StrQuery = "SELECT * from MyTable";
        DataTable DtCustomers = new DataTable();
        using (SqlConnection oConn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionstring"].ConnectionString))
        {
            oConn.Open();
            SqlCommand SCmd = new SqlCommand(StrQuery, oConn);
            SqlDataReader SDr = SCmd.ExecuteReader();
            DtCustomers.Load(SDr);
        }
        Console.ReadKey();
    }
}