解决SQL注入攻击的问题 [英] Solving the problem of SQLinjection

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

问题描述

有关我的登录控制,我在SQL语句中使用的参数。麻烦的是,如果人们使用SQL注入攻击,恐怕他们将能够在太搞定。

For my login control I'm using parameters in an SQL statement. Trouble is if people use SQLinjection, I'm afraid they'll be able to get in too.

我有两个文本框和值传递给SQL语句,这种检查是否值在数据库中。

I have two textboxes and the values are passed on to an SQL statement, this checks whether the values are found in the DB.

有没有一种办法,以确保这是不可能的?我知道,在PHP中,你需要使用的东西盈文本框的。

Is there a way to make sure this isn't possible? I know in PHP you need to use something infront of the textboxes.

感谢您的时间!

推荐答案

在查询中使用的参数:

// C#
SqlCommand cmd = new SqlCommand("UPDATE Products SET description = @Description WHERE id = @ID");
cmd.Parameters.AddWithValue("@Description", "something");
cmd.Parameters.AddWithValue("@ID", 123);

和等值VB.net:

// VB.net
Dim cmd As New SqlCommand("UPDATE Products SET description = @Description WHERE id = @ID")
cmd.Parameters.AddWithValue("@Description", "something")
cmd.Parameters.AddWithValue("@ID", 123)

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

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