防止sql注入 适用于 URL ID 纯数字
例子: int id = Convert.ToInt32(replace((Request.QueryString["id"]), ""));
public static string replace(string str, string str2)
{
str = str.Replace(";", str2);
str = str.Replace("&", str2);
str = str.Replace("<", str2);
str = str.Replace(">", str2);
str = str.Replace("'", str2);
str = str.Replace("--", str2);
str = str.Replace("/", str2);
str = str.Replace("%", str2);
str = str.Replace("~", str2);
str = str.Replace(",", str2);
str = str.Replace("`", str2);
str = str.Replace("!", str2);
str = str.Replace("@", str2);
str = str.Replace("#", str2);
str = str.Replace("$", str2);
str = str.Replace("^", str2);
str = str.Replace("*", str2);
str = str.Replace("(", str2);
str = str.Replace(")", str2);
str = str.Replace("+", str2);
str = str.Replace(":", str2);
str = str.Replace("<", str2);
str = str.Replace(">", str2);
str = str.Replace("?", str2);
 
相关文档:
改善SQL语句
很多人不知道SQL语句在sql server中是如何执行的,他们担心自己所写的SQL语句会被SQL SERVER误解。比如:
select * from table1 where name=''zhangsan'' and tID > 10000
和执行:
select * from table1 where tID > 10000 and name=''zhangsan''
一些人不知道以上两条语句的执行效率是否一 ......
SQL SERVER登录用户在服务器上的权限
一个登录用户到底在SQL SERVER实例上有什么样的权限,下面以SQL SERVER2005为例来细数一下。
一.
首先查看该登录用户属于哪个固定服务器角色。所有SQL SERVER的登录用户和角色都会在master.sys.server_principal视图上有一条记录。而记录登录用户属于什么服务器角色的视图是master. ......
DDL—数据定义语言(CREATE,ALTER,DROP,DECLARE)
DML—数据操纵语言(SELECT,DELETE,UPDATE,INSERT)
DCL—数据控制语言(GRANT,REVOKE,COMMIT,ROLLBACK)
首先,简要介绍基础语句:
1、说明:创建数据库
CREATE DATABASE database-name
2、说明:删除数据库
drop database ......
首先配置SQLSERVER2005:
打开”Microsoft SQL Server Management Studio“ 直接用Windows 用户连接进入,再在“安全性”中的“登录名”内的“新建登录名”,你就对应的添好“确定”就可以了。
再在你对应的“数据库”里“安全性” ......
{
SqlConnection cnn = new SqlConnection
("context connection=true");
cnn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;
cmd.CommandText = "select * from customers";
SqlDataReader reader = cmd.ExecuteReader();
SqlContext.Pipe.Send(reader);
reader.Close();
cnn.Close();
}
......