with little of made 2 query. posted pictures can see in green squares empty values see , in red squares values wouldnt display. variable vyberradek inserts values 'subkey' int in db pass through string.
so simplify: can display or little, me how display correct records?
this first query this:

string squery = string.format("select zajsluz.akce,zajsluz.text,klisluz.pocet,klisluz.subkey,zajsluz.id zajsluz left join klisluz on zajsluz.id=klisluz.idzajsluz zajsluz.akce= '{0}' group klisluz.subkey,zajsluz.akce,zajsluz.text,klisluz.pocet,zajsluz.id", szakce); here second query: 
string squery = string.format("select zajsluz.akce,zajsluz.text,klisluz.pocet,klisluz.subkey,zajsluz.id zajsluz left join klisluz on zajsluz.id=klisluz.idzajsluz zajsluz.akce= '{0}' , klisluz.subkey ='" + vyberradek + "' group klisluz.subkey,zajsluz.akce,zajsluz.text,klisluz.pocet,zajsluz.id", szakce); so can see display empty ones. think might need code checks checkboxes here is:
(int = 0; < dtg_ksluzby.rows.count; i++) { var row = dtg_ksluzby.rows[i]; int id = (int)row.cells["id"].value; using (var novyprikaz3 = new sqlcommand("select * klisluz subkey='" + vyberradek + "'and idzajsluz=" + id, spojeni)) { spojeni.open(); sqldatareader precti3 = novyprikaz3.executereader(); if (precti3.hasrows) { row.cells[5].value = true; } spojeni.close(); } } would guys please suggest me how should query select non checked value (which arent in table klisluz) , checked ones?
as see nobody replying let me give 1 simple example: when create client check example 3 10 checkboxes. selects 3 rows (and adds table klisluz). , have these 2 queries, first query shows checked checkbox other clients, non-checked ones client. shows in database, shows rows checked things of other clients (but same , other client/s, doesnt create duplicates). second shows checked client without havent choosen. when edit of client display did checked , rest 7(the 7 possibilities haven't checked check them). can display did checked (without non-checked) or including other clients checks (which same client). hope understandable, sorry weak english.
p.s. check mean checking checkbox (selecting row) program adds service clients.
thank interest , reading if read all. im stuck issue 2 days :/
picture kwwallpe: can see here "nic" has never been selected costumer displayed.
to make question more clear - take of these columns table (as can see in sql query).
this kwwallpe's code:
string squery = string.format("select zajsluz.akce,zajsluz.text,klisluz.pocet,klisluz.subkey,zajsluz.id zajsluz left join klisluz on zajsluz.id=klisluz.idzajsluz zajsluz.akce= '{0}' , isnull(klisluz.subkey, '" + vyberradek + "') = '" + vyberradek + "' group klisluz.subkey,zajsluz.akce,zajsluz.text,klisluz.pocet,zajsluz.id", szakce); this code way close think 2. because select values have never been selected costumer b4. can see hat "nic" displayed because not in table klisluz.

if i'm understanding you're after, part that's keeping getting rows no entries in klisluz:
where zajsluz.akce= '{0}' , klisluz.subkey ='" + vyberradek + "' for rows don't exist in klisluz, subkey null, won't match clause. these rows well, can replace current clause with:
where zajsluz.akce= '{0}' , isnull(klisluz.subkey, '" + vyberradek + "') ='" + vyberradek + "' here's full line of code:
string squery = string.format("select zajsluz.akce,zajsluz.text,klisluz.pocet,klisluz.subkey,zajsluz.id zajsluz left join klisluz on zajsluz.id=klisluz.idzajsluz zajsluz.akce= '{0}' , isnull(klisluz.subkey, '" + vyberradek + "') = '" + vyberradek + "' group klisluz.subkey,zajsluz.akce,zajsluz.text,klisluz.pocet,zajsluz.id", szakce); to determine whether checkbox should checked:
if (precti3.hasrows) { precti3.read(); if (precti3.item("subkey") != null) { row.cells[5].value = true; } else { row.cells[5].value = false; } } i think that's how it'd go in c#. work in vb.net, used online converter this.
Comments
Post a Comment