Breaking News

Editors Picks

Thursday, February 2, 2012

In Asp.net Quick Wayto Filling a DataTable or DataSet the


private DataTable GetDataTable()
    {
        string sql = "SELECT recID,Main_Node_Name,IsActive from  ea_treeview";
        using (SqlConnection myConnection = new SqlConnection(connectionString))
        {
            using (SqlCommand myCommand = new SqlCommand(sql, myConnection))
            {
                myConnection.Open();
                using (SqlDataReader myReader = myCommand.ExecuteReader())
                {
                    DataTable myTable = new DataTable();
                    myTable.Load(myReader);                  
                    return myTable;
                }
            }
        }
    }

No comments :

Post a Comment

Contact Us

Name

Email *

Message *