sql - I need to calculate and the display the sum of the total sales in C# -


i want calculate sum of total sales staff id , calculate total sales month in c# keeps saying input string wrong.

here code total sales staff id

 command.commandtext = "select sum (pricesold) saleline saleline.soldby = '" +  combobox10.selecteditem.tostring() + "' ";         string cmd = command.commandtext;         double result = convert.todouble(cmd);         textboxsalesstaffoutput.text = convert.tostring(result); 

here code sales month

 command.commandtext = " select sum (saletotalvalue) sales sales.saledate between '" + textboxdate1.text + "' , '" + textboxdate2.text + "'";         string cmd = command.commandtext;         textboxsalesmonthoutput.text = convert.tostring(cmd); 

any ideas of do.

you not executing commands. can execute them via executescalar return 1 row , 1 column. here example first query :

double result = convert.todouble(cmd.executescalar()); 

as mentioned in comments @babaknaffas, consider using parameters :

command.commandtext = "select sum (pricesold) saleline saleline.soldby = @vendor "; command.parameters.addwithvalue("@vendor", combobox10.selecteditem.tostring()); 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -