c# - display count in textbox -


i have simple problem. have table in dataset designer have query

select count(sex) male, count(sex) female tblpersonalinfo 

can please show me how display male , female count in 2 textboxes? , can please check if query correct? i'm newbie in visual studio c# 2010.

form previous projects, use these retrieve data database , display in textbox.

public maindatabasedataset.tblpositiondatatable getpositiondata(string data)         {             maindatabasedatasettableadapters.tblpositiontableadapter returnposition =  new maindatabasedatasettableadapters.tblpositiontableadapter();             return returnposition.getdatabyposition(this.txtsearch.text.trim());          }  }  private void btncompletesearch_click(object sender, eventargs e)         {                      maindatabasedataset.tblpositiondatatable getpositioncommand1 = getpositiondata(this.txtsearch.text);                     maindatabasedataset.tblpositionrow getpositioncommand2 = (maindatabasedataset.tblpositionrow)getpositioncommand1.rows[0];                     this.txtmainposition.text = getpositioncommand2.position.tostring();               } 

and use query:

select   position       tblposition    (id = @idmain) 

without seeing code or background it's impossible answer stands query produce same count male female. count males need like

select count(sex) male, tblpersonalinfo sex = 'male' 

and second query female. or else

select count(sex) tblperoncalinfo group sex 

or if need them spearate columns:

select sum(case when sex = 'male' 1 else 0 end) male,        sum(case when sex = 'female' 1 else 0 end) female tblpersonalinfo 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -