GST Billing Software

header image

Change the Query at Runtime

Erachana Line

37. How to change the query at runtime for Form, Datagrid, Listbox, Dropdown, Combobox?

During Run Time, to change the Query of the Controls mentioned, Create an Expression , in that you need to write the following code -

Dropdown -

DataTable dtBill = SqlInterpreter.GetData("select billid, billnumfull from bill where trantype = 2 order by billnum");

cmb_BillNumFull.DataSource = dtBill;

cmb_BillNumFull.ValueMember = dtBill.Columns["billid"].ToString();

cmb_BillNumFull.DisplayMember = dtBill.Columns["billnumfull"].ToString();

cmb_BillNumFull.DataSource = dtBill;


Listbox -

DataTable dtTrans = SqlInterpreter.GetData("select transeriesid, transeriesname, trantype from transeries where TranType=2");

lst_TranSeriesName.DataSource = dtTrans;

lst_TranSeriesName.ValueMember = dtTrans.Columns["transeriesid"].ToString();

lst_TranSeriesName.DisplayMember = dtTrans.Columns["transeriesname"].ToString();

lst_TranSeriesName.DataSource = dtTrans;


Datagrid -

dgrData.DataSource = SqlInterpreter.GetData("select * from Bills");