add - Sql query added to title? -


in c# windows forms:

i'm having trouble adding sql query result text toolstripmenuitem.text.

the toolstripmenuitem title should be, company + how many orders there in sql table company should update every x secounds.

every 5 seconds adds query result text. problem is "adds" it. after first 5 seconds looks ok "rexton 1" 5 seconds after shows "rexton 1 1" , on...

here code:

 //rexton ordre klar til bestilling          sqlconnection con = new sqlconnection(@"data source=" + globalvariables.hosttxt + "," + globalvariables.porttxt + "\\sqlexpress;database=ha;persist security info=false; uid='" + globalvariables.user + "' ; pwd='" + globalvariables.psw + "'");                     sqlcommand command = con.createcommand();                       command.commandtext = "select count(*) bestillinger firma = @rexton , udlevering between @date , @dateadd";                     command.parameters.addwithvalue("@bernafon", "bernafon");                     command.parameters.addwithvalue("@gn_resound", "gn resound");                     command.parameters.addwithvalue("@oticon", "oticon");                     command.parameters.addwithvalue("@phonak", "phonak");                     command.parameters.addwithvalue("@rexton", "rexton");                     command.parameters.addwithvalue("@siemens", "siemens");                     command.parameters.addwithvalue("@widex", "widex");                      con.open();                     command.executenonquery();                     string result = command.executescalar().tostring();                      con.close();                      if (result != "0")                     {                         rextontoolstripmenuitem.text = rextontoolstripmenuitem.text + " " + result;                         rextontoolstripmenuitem.forecolor = system.drawing.colortranslator.fromhtml("#ff1919");                     } 

it because setting rextontoolstripmenuitem.text rextontoolstripmenuitem.text + " " + result appending previous text

either set text blank , set again or

rextontoolstripmenuitem.text = "rexton " + result 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -