In the interst to answer this correctly.
Converting a string to an int
This is done really easily with one of the various built in methods such as.
int.Parse(string s) : This will attempt to convert the value passed as s to an int (Int32). If the input string s is not a valid int the exception FormatException will be thrown
There are multiple overrides as listed here int.Parse Method
Now the key here the string must be a valid int representation anything else will throw the FormatException
So this can be used as
cmd.Parameters.Add(new SqlParameter("@modele ", int.Parse(modele_vehiclue.Text)));
How to safely validate the string
Now as we have just stated the string must be a valid int representation for this to succeed. Now if you are not 100% sure that the value of modele_vehiclue.Text property is a valid string representation of an int then you should validate it first.
Luckily this is really easy. There is a built in method called int.TryParse(string s, out int result method which returns a Boolean result (not an int).
So this could be used as.
int modele = 0;
//int.TryParse returns a true\false on operation success. The value of modele will be the converted int or zero if the operation failed.
if(int.TryParse(modele_vehiclue.Text, out modele) == true)
{
//conversion success
cmd.Parameters.Add(new SqlParameter("@modele ", modele);
}
else
{
//handle failed conversion
throw new Exception("modele_vehiclue.Text must be an int");
}
int.Parse(string)and if your not sure if the result will be a valid int then useint.TryParse(string)cmd.Parameters.Add(new SqlParameter("@modele ", int.Parse(modele_vehiclue.Text)));