private void searchLedger(string value) { cn.Open(); SqlCommand cmd = new SqlCommand("Select * from LedgerCreation Where ledgerName like '%" + value + "%' and AddClassification =@AddClassification order by LedgerName", cn); cmd.Parameters.AddWithValue("@AddClassification", "Cash/Bank"); //SqlCommand cmd = new SqlCommand(searchquery, cn); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable table = new DataTable(); da.Fill(table); LstReceipt.DataSource = table; LstReceipt.DisplayMember = "LedgerName"; cn.Close();
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (dataGridView1.CurrentCell.ColumnIndex == 1) { searchLedger(dataGridView1.CurrentRow.Cells[0].FormattedValue.ToString()); } }
new SqlCommand("Select * from LedgerCreation Where ledgerName like '%" + value + "%' and AddClassification =@AddClassification order by LedgerName", cn);
AddClassification
SqlCommand cmd = new SqlCommand("Select * from LedgerCreation Where ledgerName like @LedgerName and AddClassification = @AddClassification order by LedgerName", cn); cmd.Parameters.AddWithValue("@AddClassification", "Cash/Bank"); cmd.Parameters.AddWithValue("@LedgerName", "%" + value + "%");
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)