Hello,
I am trying to insert mobile number into a variable which is of type int (in sqlserver's database table) from Asp.Net's Textbox control and I am getting this exception
System.Data.SqlClient.SqlException: Error converting data type nvarchar to int.
my code is as follows....
in .aspx file
<asp:TableRow>
<asp:TableCell>Mobile No</asp:TableCell><asp:TableCell>:</asp:TableCell><asp:TableCell>
<asp:TextBox ID="txtMob" runat="server" TextMode="Phone" /></asp:TableCell>
</asp:TableRow>
in .aspx.cs file
SqlParameter p13 = new SqlParameter("Mobile",txtMob.Text.Trim());
cmd.Parameters.Add(p14);
int rowAffected = cmd.ExecuteNonQuery();
when I am trying in the above way i am getting "Error converting data type nvarchar to int." Exception
and when I'm trying to convert data type to int i.e.,
SqlParameter p13 = new SqlParameter("Mobile",Convert.ToInt32(txtMob.Text.Trim()));
when i go for conversion i am getting "System.OverflowException: Value was either too large or too small for an Int32." exception
could anyone please provide solution for my problem???