验证Varchar DataType的TextBox? [英] Validate a TextBox for Varchar DataType ?

查看:70
本文介绍了验证Varchar DataType的TextBox?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个TextBox输入字段,有时当用户提交数据时我从sql端发现错误除了最大长度错误。所以请提供我们如何验证textBox只能防止那些可能从SQL Server生成错误的东西我认为,

使用Varchar(MAX)数据类型并在SQL SERVER中使用SET QUOTED_IDENTIFIER ON


我认为你提供类型验证: -

(1)最大长度验证。

(2)防止使用单一的上部引号( ie'')因为这使SQL混淆了不同的String.Try使用 INSERT INTO文本VALUES(''/''/'''')


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.

解决方案

As I think,
use Varchar(MAX) data type and use SET QUOTED_IDENTIFIER ON in SQL SERVER


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(''/''/'''')


这篇关于验证Varchar DataType的TextBox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆