Hi all,
i'm doing a program using c# in creating an insert page..
i want to insert the zip code into the databse and have been validate using validation expression..

<asp:TextBox ID="txtCmpZip" runat="server" BorderStyle="Groove" MaxLength="10" Width="74"></asp:TextBox><asp:RequiredFieldValidator ID="CmpZip" runat="server" ErrorMessage="*" ControlToValidate="txtCmpZip"></asp:RequiredFieldValidator>
                            <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender2" runat="server" TargetControlID="RegularExpressionValidator2"></asp:ValidatorCalloutExtender>
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator2" ErrorMessage="Zip code must at least 5 digits" ValidationExpression="\d{5,10}" Display="None" runat="server" ControlToValidate="txtCmpZip"></asp:RegularExpressionValidator>

when i insert "999999999", it will giving me an error said

error converting data type nvarchar to int.

but for the other zip code, it will insert successfully.. any help plz?

What is the data type of zip field in a table?

int..
in the usp also int..it's happens only if i'm insert 9999999999

The reason is it's exceeding the size of int.

You can store the data in between -2,147,483,648 to 2,147,483,647

int..
in the usp also int..it's happens only if i'm insert 9999999999

i see..
so, is there any validation for that error?
any suggestions?

convert your database feild with bigint instead of int or make it as numeric

Thanks..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.