var strsql = "insert into Staff_Answer (ExamTitleID,QuestionsID,MultipleChoice,RightOption,AnswerOption,IsRight,Score,StaffScore,Remark,State,Creator,CreatOrg,CreateTime) values";
        strsql += "(@ExamTitleID,@QuestionsID,@MultipleChoice,@RightOption,@AnswerOption,@IsRight,@Score,@StaffScore,@Remark,@State,@Creator,@CreatOrg,@CreateTime)";
        var cmd = new SqlCommand(strsql);
        var param = new SqlParameter[] {
                                                  new SqlParameter("@ExamTitleID",SqlDbType.UniqueIdentifier),
                                                  new SqlParameter("@QuestionsID",SqlDbType.UniqueIdentifier),
                                                  new SqlParameter("@MultipleChoice",SqlDbType.NVarChar,2),
                                                  new SqlParameter("@RightOption",SqlDbType.NVarChar,200),
                                                 new SqlParameter("@AnswerOption",SqlDbType.NVarChar,200),
                                                 new SqlParameter("@IsRight",SqlDbType.NVarChar,2),
                                                new SqlParameter("@Score",SqlDbType.Decimal,18),
                                                 new SqlParameter("@StaffScore",SqlDbType.Decimal,18),
                                                new SqlParameter("@Remark",SqlDbType.Text),
                                                 new SqlParameter("@State",SqlDbType.NVarChar,2),
                                                 new SqlParameter("@Creator",SqlDbType.NVarChar,200),
                                                 new SqlParameter("@CreatOrg",SqlDbType.NVarChar,200),
                                                 new SqlParameter("@CreateTime",SqlDbType.NVarChar,200)
                                             };

param[0].Value = new Guid(this.ExamTitleCode.Value);
        param[1].Value = new Guid(QuestionsID);
        param[2].Value = Anserdt.Rows[0]["MultipleChoice"].ToString();
        param[3].Value = RightOption;
        param[4].Value = AnswerOption;
        param[5].Value = ISRight ? "1" : "0";
        param[6].Value = Convert.ToInt32(Question.Rows[0]["Score"]);
        param[7].Value = ISRight ? Convert.ToInt32(Question.Rows[0]["Score"]) : 0;
        param[8].Value = this.Remark.InnerText;
        param[9].Value = "1";
        param[10].Value = userid;
        param[11].Value = Orgname1;
        param[12].Value = DateTime.Now;

foreach (SqlParameter para in param)
        {
            cmd.Parameters.Add(para);
        }
        helps.GetExecuteNonQueryBySqlPa(cmd);

SQL 防止注入的更多相关文章

  1. 在Hdsi2.0 SQL的注入部分抓包分析语句

    在Hdsi2.0 SQL的注入部分抓包分析语句 恢复cmd ;insert tb1 exec master..xp_cmdshell''net user ''-- ;exec master.dbo.s ...

  2. SQL防注入程序 v1.0

    /// ***************C#版SQL防注入程序 v1.0************ /// *使用方法: /// 一.整站防注入(推荐) /// 在Global.asax.cs中查找App ...

  3. PHP之SQL防注入代码集合(建站常用)

    SQL防注入代码一 <?php if (!function_exists (quote)) { function quote($var) { if (strlen($var)) { $var=! ...

  4. 小白日记41:kali渗透测试之Web渗透-SQL手工注入(三)-猜测列名、表名、库名、字段内容,数据库写入

    SQL手工注入 靶机:metasploitable(低)  1.当无权读取infomation_schema库[MySQL最重要的源数据库,必须有root权限]/拒绝union.order by语句 ...

  5. 小白日记40:kali渗透测试之Web渗透-SQL手工注入(二)-读取文件、写入文件、反弹shell

    SQL手工注入 1.读取文件[load_file函数] ' union  SELECT null,load_file('/etc/passwd')--+ burpsuite 2.写入文件 ' unio ...

  6. 小白日记39:kali渗透测试之Web渗透-SQL手工注入(一)-检测方法

    SQL手工注入(一) SQL注入:通过把SQL命令插入到Web表单递交或输入域名或页面请求的查询字符串,最终达到欺骗服务器执行恶意的SQL命令.[SQL注入原理] ##服务端程序将用户输入参数作为查询 ...

  7. PreparedStatement可以有效地防止sql被注入

    import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import jav ...

  8. php正则验证sql方注入

    <?php function inject_check($Sql_Str) {//自动过滤Sql的注入语句. $check=preg_match('/select|insert|update|d ...

  9. SQL语句查询时防止SQL语句注入的方法之一

    1.传参时有可能出现SQL语句注入 StringBuffer sb = new StringBuffer(); if(StringUtils.isNotBlank(areaCode)) { sb.ap ...

  10. Kali学习笔记42:SQL手工注入(4)

    前三篇文章都是在讲发现SQL注入漏洞 如何查询得到所有的信息 那么另一条思路还未尝试过:能否修改数据? 例如这样: '; update users set user='yiqing' where us ...

随机推荐

  1. MySQL 之 Index Condition Pushdown(ICP)

    简介 Index Condition Pushdown (ICP)是MySQL 5.6 版本中的新特性,是一种在存储引擎层使用索引过滤数据的一种优化方式. 当关闭ICP时,index 仅仅是data ...

  2. linux基础命令学习(二)文件和目录操作

    1.变换当前目录(change directory)     cd /home 进入 '/ home' 目录'  (change directory)   cd .. 返回上一级目录    cd .. ...

  3. 几种OutOfMemoryError

    JAVA虚拟机OutOfMemoryError主要包括以下四类:java.lang.OutOfMemoryError: Java heap spacejava.lang.OutOfMemoryErro ...

  4. shell之if简化语句

    最常用的简化if语句: && 如果是“前面”,则“后面” [ -f /var/run/dhcpd.pid ] && rm /var/run/dhcpd.pid 检查 文 ...

  5. Rob Pike 的 5 个编程原则

    原则 1. 你没有办法预测每个程序的运行时间,瓶颈会出现在出乎意料的地方,所以在分析瓶颈原因之前,先不要盲目猜测. 原则 2. 测试(measure).在测试之前不要优化程序,即使在测试之后也要慎重, ...

  6. WPF性能调试系列 – Ants Performance Profiler

    WPF性能调试系列文章: WPF页面渲染优化:Application Timeline WPF页面业务加载优化:Ants Performance Profiler WPF内存优化:Ants Memor ...

  7. Matplotlib Tutorial(译)

    Matplotlib Tutorial(译) 翻译自:Matplotlib tutorialNicolas P. Rougier - Euroscipy 2012 toc{: toc} 这个教程基于可 ...

  8. 写的一个split函数

    vector<string> strsplit(const string& str) { vector<string> vec; string sstr1=str, s ...

  9. C语言不定参数

    最近,遇到一个c语言的不定参数问题.其实,对于c语言的不定参数问题,只需要三个函数就可以搞定了.这三个函数的头文件是<stdarg.h>,其实下面的三个函数都是一个宏定义(macro).  ...

  10. 硬件加速 Hardware Accelerated 绘制

    官方文档中对硬件加速的描述 原文地址:http://developer.android.com/guide/topics/graphics/hardware-accel.html Beginning ...