SQL注入在.NET [英] SQL Injection in .NET

查看:138
本文介绍了SQL注入在.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我想知道是否有人知道一些好的网站,详细说明prevention SQL注入的.NET Web应用程序中。任何资源将大大appricated,谢谢你。

Hi I was wondering if anyone knew of some good websites detailing prevention for SQL injection for .NET web applications. Any resources would be greatly appricated, thank you.

推荐答案

我认为,如果你google了一下关于preventing SQL注入在.NET',你会发现很多很好的资源。 :)

I think that, if you google a bit on 'preventing sql injection in .NET', you'll find lots of good resources. :)

总之,一件非常重要的事情,是不使用字符串串联,以建立查询。 相反,使用参数化查询。 ADO.NET允许做到这一点,在一个非常简单的方法:

Anyway, one very important thing, is to not use string-concatenation in order to build your queries. Instead, use parametrized queries. ADO.NET allows to do this, in a very easy way:

string sql = "SELECT * FROM Persons WHERE Persons.Lastname LIKE @p_Name";

SqlCommand cmd = new SqlCommand (sql);

cmd.Parameters.Add ("@p_Name", SqlDbType.Varchar).Value = textBox1.Text + "%";

这篇关于SQL注入在.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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