c# - Parameter is not valid Exception in windowsForm -


i using multi panels making multi section project , using access database , inserting thing in below:

    private void addmoneypanel_firstload()     {         try         {             employee_list.items.clear();             connection.open();             oledbcommand command = new oledbcommand();             command.connection = connection;              command.commandtext = "select ename,elastname employee";             oledbdatareader reader = command.executereader();             while(reader.read())             {                 employee_list.items.add(reader[0].tostring() + " \n" +reader[1].tostring());             }             connection.close();             /*addmoneypanelmes.text = "با موفقیت ذخیره شد.";             addmoneypanelmes.forecolor = color.green;*/          }         catch (exception err)         {             addmoneypanelmes.text = "خظا در ارتباط با پایگاه داده.";             addmoneypanelmes.forecolor = color.red;             addmoneypanelmes.visible = true;         }     }     private void picturebox1_click_1(object sender, eventargs e)     {         try         {             string tempprice, tempchecknum, tempcriditnum;             connection.open();             oledbcommand command = new oledbcommand();             command.connection = connection;             if(radiobutton1.checked == true)             {                 tempprice = money_price.text;                 tempchecknum = "0";                 tempcriditnum = "0";             }else if(radiobutton2.checked == true)             {                 tempprice = money_price.text;                 tempchecknum = "0";                 tempcriditnum = criditnumber.text;             }             else             {                 tempprice = money_price.text;                 tempchecknum = checknumber.text;                 tempcriditnum = "0";             }             ///////////////////////////////split combo box names             string maintosplit,id = "";             string[] splited;             maintosplit = employee_list.selecteditem.tostring();             splited = maintosplit.split('\n');             splited[0] = "" + splited[0].remove((splited[0].length-1),1);              command.commandtext = "select id employee ename='" +splited[0]+ "' , elastname='" +splited[1]+"'";             oledbdatareader reader = command.executereader();             if (reader.read())                 id = reader[0].tostring();               connection.close();              connection.open();             oledbcommand command2 = new oledbcommand();              command2.connection = connection;             command2.commandtext = "insert realmoney (price,cardnum,checknum,thedate,employeeid,descrip) values(" + int32.parse(tempprice) + "," + int32.parse(tempcriditnum) + "," + int32.parse(tempchecknum) + ",#" + datetimepickerx1.getselecteddateinpersiandatetime().toshortdatestring() + "#," + int32.parse(id) + ",'" + money_descrip.text + "')";             command2.executenonquery();             connection.close();             addmoneypanelmes.text = "با موفقیت ذخیره شد.";             addmoneypanelmes.forecolor = color.green;             addmoneypanelmes.visible = true;          }          catch(oledbexception h)         {             addmoneypanelmes.text = "خظا در ارتباط با پایگاه داده.";             addmoneypanelmes.forecolor = color.red;             addmoneypanelmes.visible = true;         }     } 

this 2 function run after "parameter not valid" exception in part:

   private void timer1_tick(object sender, eventargs e)     {         if(pass == 0 || pass == 1)         {             prossespass();         }         datetime datetime = datetime.now;         try         {             time.text = string.format("{0:hh:mm:ss}", datetime.now); // error here             timesun.text = datetime.tostring("tt");         }         catch(exception d)         { }      }  

this timer clock in project. after returning main panel clock existing in (make main panel visible , hide current panel) clock text box cant set , project crashed. dont know problem is. if erase part second function mentioned:

  addmoneypanelmes.text = "با موفقیت ذخیره شد.";             addmoneypanelmes.forecolor = color.green;             addmoneypanelmes.visible = true; 

or removing insert section in second function above:

connection.open();             oledbcommand command2 = new oledbcommand();              command2.connection = connection;             command2.commandtext = "insert realmoney (price,cardnum,checknum,thedate,employeeid,descrip) values(" + int32.parse(tempprice) + "," + int32.parse(tempcriditnum) + "," + int32.parse(tempchecknum) + ",#" + datetimepickerx1.getselecteddateinpersiandatetime().toshortdatestring() + "#," + int32.parse(id) + ",'" + money_descrip.text + "')";             command2.executenonquery();             connection.close(); 

i have other function in other panels work database work great it. help.

just turn timer off:

timer1.enabled = false; 

when enter each panel , turn on when come main panel:

timer1.enabled = true; 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -