Click here to Skip to main content
15,562,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have B.Items to use as field or criteria sort and filter A.Column[j]
public void sorting(DataGridView A, ComboBox B, string Column)
        {
            query = "Select * from schTable ";
            static string path = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Application.StartupPath + "\\dBase.accdb";
            OleDbCommand cmd = new OleDbCommand();
            OleDbDataAdapter adt = new OleDbDataAdapter();
            OleDbConnection con = new OleDbConnection(path);
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();

            DataObjectsInitialization();
            con.Open();
            cmd.Connection = con;
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = query;
            adt.SelectCommand = cmd;
            adt.SelectCommand.ExecuteNonQuery();
            con.Close();
            adt.Fill(ds);
            dt = ds.Tables[0];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i].Cells[Column].Value.Equals(B.SelectedItem))
                {
                  //A.Clear();
                  //A.Rows.Add(dt.Rows[i].Cells[Column]);
                }
            }
        }

From dt = ds.Tables[0]; my codes do not communicate anymore; all pleasure will be mine if you can assist me to:
1. Access the DataTable like DataGridView.
2. Clear or delete rows from DataGridView at run time while the DataSource equals dataBase?
Thank you.
Posted
Updated 30-May-14 2:38am
v2
Comments
Did you debug and see what is the issue?
Salisu Shaibu 30-May-14 13:10pm    
The issue is, I can't complete the codes to do what I really want to do.
Please help!
RDBurmon 30-May-14 10:00am    
whats the error??
Salisu Shaibu 30-May-14 13:11pm    
No error its just that I can't complete the codes to do what I really want to do.
Please help!

1 solution

DataView dv = new DataView(ds.Tables[0], "Price > 19", "Price Desc", DataViewRowState.CurrentRows);
dataGridView1.DataSource = dv;


Use dataview
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900