Click here to Skip to main content
16,016,501 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
while (dr.Read())
                {
                    //s1 = dr[0].ToString();
                    s2 = dr[1].ToString();
                    s3 = dr[4].ToString();
                    s4 = dr[5].ToString();
                    s5 = dr[6].ToString();

                    flag = 1;

                }
                if (flag == 1)
                {


                    textBox3.Text = s2;
                    textBox4.Text = s3;
                    textBox5.Text = s4;
                    numericUpDown1.Value = s5;
                    MessageBox.Show("found");
                }

}

This code i am writing to fetch the details from database and get them in new form and do modification but quantity which is numericupdown of integer type in database is not coming in new form . Please help me..
Posted
Comments
Member 10403595 4-Jan-14 6:49am    
Thank you..
It is working..
Thomas Daniels 4-Jan-14 6:53am    
If there is a solution that is working for you, then click on the "Accept Solution" button for the answer that helped you.

Also, your comment looks like a comment to an answer. If you want to comment to an answer, click on the "Have a Question or Comment?" button below the answer.
BillWoodruff 4-Jan-14 9:59am    
In this case the Type of the value to be assigned to the NumericUpDown Control is important to specify.

If what you retrieve from the database is a Double, or string, it will require conversion to Type Decimal; if it's an Int, it will not.

on top of ProgramFox solution....

another simple and common way is like

C#
numericUpDown1.Value =  Convert.ToDecimal( s5);
 
Share this answer
 
Instead of this:
C#
s5 = dr[6].ToString();

Try this:
C#
s5 = dr.GetInt32(6);

You also need to change the type of s5 from string to int.

If the value in the database is not an int, but a double, use GetDouble, and if the value is a decimal, use GetDecimal.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900