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]); } } }
dt = ds.Tables[0];
DataView dv = new DataView(ds.Tables[0], "Price > 19", "Price Desc", DataViewRowState.CurrentRows); dataGridView1.DataSource = dv;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)