sql - C# cant populate datagridview -
i had similar problem , shown how fix it, tried post on same thread limited.
i have method private void filllevyroll(), put method in button on click event fill datagridview dgvlevyroll problem when run not getting error , dgv remaining empty.im lost confused tried no avail.
the query works in sql management studio
private void filllevyroll() { try { datatable datatablesource = new datatable(); sqlcommand command = new sqlcommand("select refrence" + ", max(case when accnumber = '1010000' amount end) opening" + ", max(case when accnumber = '1010000' amount end) electricity" + ", max(case when accnumber = '1045000' amount end) water" + ", max(case when accnumber = '1000000' amount end) levy" + ", max(case when accnumber = '2750000' amount end) interest" + ", max(case when accnumber = '4000000' amount end) legal" + ", max(case when accnumber = '4350003' amount end) other" + ", max(case when accnumber = '8400000' amount end) payments" + ", max(case when accnumber = '1000000' amount end) due" + " dbo.vw_ledgertransactions" + " group refrence ", conn); sqldataadapter adapter = new sqldataadapter(command); conn.open(); adapter.fill(datatablesource); dgvlevyroll.datasource = datatablesource; } catch (exception ex) { messagebox.show("application error. err:" + ex.tostring()); } { conn.close(); } }
Comments
Post a Comment