i have a class called querys , and inside it i have function like code below
public void insertdata(int x1, string x2, string x3, int x4, string x5)
{
try
{
string insert = string.Format("insert into [customer] ([cust_id],[cust_arabic_name],[cust_english_name],[cust_mobile],[cust_address]) values ('{0}','{1}','{2}','{3}','{4}')",x1, x2, x3, x4, x5);
OleDbCommand cmd = new OleDbCommand(insert,mf.con);
cmd.ExecuteNonQuery();
MessageBox.Show("new data added");
}
catch (System.InvalidOperationException ex)
{
MessageBox.Show(ex.Message);
}
}
and on my form have the following code inside the button
query.insertdata(int.Parse( Id_TBox.Text + ""), A_Name_TBox.Text + "", E_Name_TBox.Text + "", int.Parse(Mobile_TBox.Text + ""), Address_TBox.Text + "");
i changed the Id_TBox max length to be (9) and the Mobile_TBox max length to be (10).
now when i am trying to insert data an error shows (value was either too large or too small for int32).
i change it to decimal but the error is come again.
Any help please
Int32. You should be storing phone numbers in the database asstring, notint.