c# - How to set my NumericUpDown on Database -


for example, item_quantity on table 50, numericupdown's minimum 1 , 50? im using c# , mysql , cant make work.

edit:

this code:

string myconnectionstring = "server=localhost;port=3307;database=invpos;uid=root;pwd=''";      public void loadgrid()     {         mysqlconnection connection = new mysqlconnection(myconnectionstring);         connection.open();          try         {             mysqlcommand cmd = connection.createcommand();             cmd.commandtext = "select * items";             mysqldataadapter adap = new mysqldataadapter(cmd);             dataset ds = new dataset();             adap.fill(ds);         }         catch (exception)         {             throw;         }                 {             if (connection.state == connectionstate.open)             {                 connection.clone();             }         }     }      public void combobox()     {         mysqlconnection connection = new mysqlconnection(myconnectionstring);         connection.open();                 mysqlcommand cmd = connection.createcommand();         mysqldataadapter adap = new mysqldataadapter("select item_name items", connection);         dataset ds = new dataset();         adap.fill(ds);         combobox1.datasource = ds.tables[0];         combobox1.displaymember = "item_name";     }          private void form4_load(object sender, eventargs e)     {         loadgrid();         combobox();      } 

i hope can me :(

this want happen: example: database: item_quantity = 50 , want set numericupdown's maximum value item_quantity's value :(

as understand, don't know how maximum value of numericupdown?

try this:

int itemquantity = numericupdown1.maximum; //get maximum value of `numericupdown` int currentvalue = numericupdown1.value; //get current value of `numericupdown` 

does solve problem?

*update

try  {    mysqlcommand cmd = connection.createcommand();    cmd.commandtext = "update <your table> set <column> = " + itemquantity;    //use command parameter better.    cmd.executenonquery(); //execute update. } catch (exception ex) {    //catch exception } 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -