惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

博客园 - 阿春

培养领袖气质 带游标的存储过程 SQL语句集锦 (转) 正则表达式基础知识(转) http://www.cnblogs.com/pwqzc/archive/2006/06/12/423651.html(转,好东东) 脏字典 转 测试网站各项性能的31 个免费在线工具 最佳的75个网络安全工具 (转载) 截断表内容 和 删除表 利用.NET2.0自带的数据库访问工厂写的数据库访问基类 sql 语句 :取总数 下载指定URL的HTML代码 工厂模式的数据库连接 执行查询语句 给一个文本 和 编码类型 转换成 规定类型的 URL 编码 C#采集器 ss 触发器 程序调用sql
防止注入的sql调用
阿春 · 2008-03-01 · via 博客园 - 阿春

 int KeChengHao = int.Parse(this.textBox1.Text.Trim());

            System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection("Data Source=127.0.0.1;Initial Catalog=Student;User ID=sa;PassWord=58");

            System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("delete from 课程表 where 课程号=@课程号", con);
            cmd.CommandType = CommandType.Text;  //防止这样注入 delete from 课程表 where 课程号=1 or 1=1

            System.Data.SqlClient.SqlParameter p = new System.Data.SqlClient.SqlParameter("@课程号", SqlDbType.Int, 4);
            p.Value = KeChengHao;

            cmd.Parameters.Add(p);

            con.Open();
            int changeline = cmd.ExecuteNonQuery();
            con.Close();

            label2.Text = "数据库更改行数" + changeline.ToString();