防止页面在跳转的时候被SQL注入
首先写一个SQL注入过滤的类:
public class SqlFilter
{
#region SQL注入式攻击代码分析
/// <summary>
/// 处理用户提交的请求
/// </summary>
public void StartProcessRequest()
{
string getkeys = "";
string sqlErrorPage = "~/no.html";//转向的错误提示页面
try
{
if (System.Web.HttpContext.Current.Request.QueryString != null)
{
for (int i = 0; i < System.Web.HttpContext.Current.Request.QueryString.Count; i++)
{
getkeys = System.Web.HttpContext.Current.Request.QueryString.Keys[i];
if (!ProcessSqlStr(System.Web.HttpContext.Current.Request.QueryString[getkeys]))
{
System.Web.HttpContext.Current.Response.Redirect(sqlErrorPage,false);
System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest();
//System.Web.HttpContext.Current.Response.End();
}
}
}
if (System.Web.HttpContext.Current.Request.Form != null)
{
for (int i = 0; i < System.Web.HttpContext.Current.Request.Form.Count; i++)
{
getkeys = System.Web.HttpContext.Current.Request.Form.Keys[i];
if (getkeys == "__VIEWSTATE") continue;
if (!ProcessSqlStr(System.Web.HttpContext.Current.Request.Form[getkeys]))
{
System.Web.HttpContext.Current.Response.Redirect(sqlErrorPage,false);
System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest();
//System.Web.HttpContext.Current.Response.End();
相关文档:
表中有一些记录内容重复,也就是说这些记录除了ID不同之外,其他的信息都相同。需要把重复的记录保留一条,剩下的删除
--第一种方法
delete from temp where id not IN (select min(id) from temp group by col1,col2)
--对col1,col2,即要删除的数据col1,col2两个列都相同,删除id大的行
--第二种方法
with a as
(sel ......
游标:指向处理SQL语句的环境区域的指针或句柄
-----|-1 静态游标
|---1.1 隐式游标
| 处理:INSERT,DELETE,UPDATE及返回一行的SELECT语句
| ......
--语 句 功 能
--数据操作
SELECT --从数据库表中检索数据行和列
INSERT --向数据库表添加新数据行
DELETE --从数据库表中删除数据行
UPDATE --更新数据库表中的数据
--数据定义
CREATE TABLE --创建一个数据库表
DROP TABLE --从数据库中删除表
......
1、实现行列动态转换,常用于主从表关联时的特殊需求
select rwbm,psqh,
max(decode(xh1,1,yy))JKYL1,
max(decode(xh1,2,yy))JKYL2,
&n ......
今天从数据库中查询出xml,同时添加一个根节点
做了如下测试:
create table TestXmlQuery(
ID int identity(1,1) not null,
Name varchar(10)
)
go
insert into [TestXmlQuery] (Name) values('测试1')
insert into [TestXmlQuery] (Name) values('测试2')
insert into [TestXmlQuery] (Name) values('测试3')
......