Click here to Skip to main content
15,914,500 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a TextBox input field ,some times when user submit the data i found error from sql side except that maximum lenght error.So please provide how we validate that textBox that only prevent that thing that may generate the error from SQL Server side.
Posted
Comments
Thanks7872 17-May-13 1:13am    
Problem is not with textbox its with datatype in database.Make sure you have all the datatypes that can store the data you provide,and the other thing is that you can make textbox such that it only accepts specified values or values with specified length.
sri senthil kumar 17-May-13 1:16am    
what sort of input characters you gave and tested? because for varchar it should accept any character type. Sometimes error may happen when you give quoted value in that case you have to add a escape character or encode them before taking them to the DB.

As I think,
use Varchar(MAX) data type and use SET QUOTED_IDENTIFIER ON in SQL SERVER
 
Share this answer
 
I think you provide to type validation :-
(1)Max Length validation.
(2)Prevent the use of single upper quote(i.e. ') because this confused the SQL to different String.Try to use INSERT INTO text VALUES('/'/'')
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900