0

I am running ASP.NET application written in C# and using SQL Server 2005. I am having a contact number textbox in which I have to enter integers alone. I want the database to get the integers alone but if I give characters also it is getting entered. How can I avoid characters to store in the database? How to code for this?

0

1 Answer 1

1

As per the information that you've provided, there are 2 things that you need to do:

  1. Validate the user input and make sure they only enter numbers in the textbox provided to enter the phone numbers.

  2. Make sure the column in your SQL table to store the contact number is an int and not a varchar/char.

Hope this makes sense.

Sign up to request clarification or add additional context in comments.

2 Comments

hi your answer is very much helpful,but it isn't working out.I tried ALTER TABLE register ALTER COLUMN contact nvarchar(50) int this query to change datatype.it is showing error.
@jeni: You used the wrong syntax. Here's how: ALTER TABLE register ALTER COLUMN contact int. But it will fail if the column still contains any non-numeric values, so first make sure you've cleaned up your data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.