SqlParameter防SQL注入的方法
来源:互联网 发布:oracle数据库自学视频 编辑:程序博客网 时间:2024/05/17 02:07
1、 SqlParameter 构造函数
参考:https://www.2cto.com/article/201402/281712.html
SqlParameter(String, SqlDbType, Int32,ParameterDirection, Byte, Byte, String, DataRowVersion, Boolean, Object,String, String, String),其参数分别代表该类使用参数名、参数的类型、参数的长度、方向、精度、小数位数、源列名称、DataRowVersion 值之一、用于源列映射的布尔值、SqlParameter 的值、此 XML 实例的架构集合所在的数据库的名称、此 XML 实例的架构集合所在的关系架构以及此参数的架构集合的名称。
2、 SqlParameter的应用
List<CommandInfo> cmd = new List<CommandInfo>();for (int i = 0; i < dt.Rows.Count; i++){ StringBuilder strSqlConfig = new StringBuilder(); strSqlConfig.Append("insert into CMB_UpdateStatus_OnlineRecord(OnlineRecordTicketNo,SiemensEmployeeName)" + " values(@Tno,@Name) "); try { SqlParameter[] paraConfig ={ new SqlParameter("@Tno", SqlDbType.NVarChar, 10), new SqlParameter("@Name", SqlDbType.NVarChar,50)}; paraConfig[0].Value = dt.Rows[i]["机票号"].ToString(); paraConfig[1].Value = dt.Rows[i]["姓名"].ToString(); cmd.Add(new CommandInfo(strSqlConfig.ToString(), paraConfig)); } catch (Exception ex) { MessageBox.Show("excel写入数据库时发生错误:{0}", ex.Message); return; } } Hippo.ExecuteSqlTran(cmd);3、 SqlParameter的基本原理是执行计划重用。即对注入后的SQL语句重新进行了编译,重新执行了语法解析。
参考:https://www.2cto.com/article/201402/281712.html
阅读全文
0 0
- SqlParameter防SQL注入的方法
- SqlParameter防 SQL注入 SqlParameter[]的声明
- Sqlparameter防SQL注入
- SQL防注入SqlParameter的使用
- 防SQL注入之SqlParameter的简单使用[C#]
- sql防注入的方法
- 防sql注入的方法
- SqlParameter防止SQL的注入
- sql防注入方法
- 防SQL注入方法
- 防sql注入方法
- sql 防注入的一种方法
- ASP防SQL注入的方法
- PHP防SQL注入的方法
- PHP防SQL注入的方法
- SQL防注入漏洞的方法
- hibernate 防sql注入的一种方法.
- 防SQL注入的快捷方法
- centos 7 yum源设置成阿里云
- 【LeetCode】532. K-diff Pairs in an Array
- 开机时如果有SIM卡,Launcher activity会启动两次
- Struts2 REST插件远程执行命令漏洞全面分析,WAF支持检测防御
- 自定义文件上传按钮样式
- SqlParameter防SQL注入的方法
- Java排查问题工具、命令总结
- GitChat · 软件工程 | 一小时教你学会 Maven 项目的构建与管理
- java模式之组合模式
- 解决Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 and 6 Web modules
- php银行卡验证
- Android Studio快捷键总结
- 互联网时代 个人信息安全亟待解决
- 欢迎使用CSDN-markdown编辑器