C#.NET防止SQL注入式攻击
1 防止sql注入式攻击(可用于UI层控制) #region 防止sql注入式攻击(可用于UI层控制)
2
3 /**/ ///
4 /// 判断字符串中是否有SQL攻击代码
5 ///
6 /// 传入用户提交数据
7 /// true-安全;false-有注入攻击现有;
8 public bool ProcessSqlStr( string inputString)
9 {
10 string SqlStr = @" and|or|exec|execute|insert|select|delete|update|alter|create|drop|count|\*|chr|char|asc|mid|substring|master|truncate|declare|xp_cmdshell|restore|backup|net +user|net +localgroup +administrators " ;
11 try
12 {
13 if ((inputString != null ) && (inputString != String.Empty))
14 {
15 string str_Regex = @" \b( " + SqlStr + @" )\b " ;
16
17 Regex Regex = new Regex(str_Regex, RegexOptions.IgnoreCase);
18 // string s = Regex.Match(inputString).Value;
19 if ( true == Regex.IsMatch(inputString))
20 return false ;
21
22 &
相关文档:
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列
......
C#中以windows验证方式连接SQL server数据库的类。很多人连接数据库时可能都是网上查了然后就连了,对于参数的含义倒是没怎么在意,偶也是(呵呵),当然我们都注重结果嘛,可是这样不容易记忆每次连的时候都是上网查,感觉挺不方便,所以索性查了一下。~~~Integrated Security=True;表示在连接数据库进行身份验证时用wind ......
有许多不同类型的数据库管理员。 一些类型的数据库管理员致力于于开发领域,而其他的一部分更重视数据库性能的调整以及仍然有一部分数据库管理员则致力于管理SQL Server的业务。 依据数据库管理员的工作环境不同,他们将执行一定数量的不同的任务。为了区分所有不同的任务,数据库管理员可能要执行我清单上所列的任务。
......
-- create by zh
-- n 是作物的时间,x 是希望在几点成熟,返回播种的时间
with t as
(
select 64 n,9 x from dual union all
select 64 n,13 x from dual union all
select 64 n,17 x from dual union all
select 64 n,20 x from dual
)
select '成熟时间:' || lpad(to_char(n),4,' ' ......