Link to home
Start Free TrialLog in
Avatar of zimmer9
zimmer9Flag for United States of America

asked on

Do you know how to modify a C# method so that the data source records are in proper "ORDER BY BRANCH" ?

I am developing a C# Windows platform application using VS2005.

When the following method gets triggered, the records do not get properly sorted by the "ORDER BY" clause.

Do you know how to modify this method so that the records are in proper "ORDER BY BRANCH" ?

private void tabControl1_Selected(Object sender, TabControlEventArgs e)
            if (e.TabPage == tabPage5)
                string connectionString = "Data Source=F,3;Initial Catalog=U;User ID =U;PWD=C;";
                string sql = "SELECT * FROM tblPSEmail ORDER BY BRANCH, EMAILADD";
                SqlConnection connection = new SqlConnection(connectionString);
                SqlDataAdapter dataadapter = new SqlDataAdapter(sql, connection);
                DataSet ds = new DataSet();
                dataadapter.Fill(ds, "tblPSEmail");
                dataGridView1.DataSource = ds;
                dataGridView1.DataMember = "tblPSEmail";
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial