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. URAL 1993 This cheeseburger you don't need 模拟题

    This cheeseburger you don't need 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=1993 Descrip ...

  2. li 标签中放a 标签,文字垂直居中

    <ul style="float:left"><li class="lili"> <a href="Left.aspx? ...

  3. The method setClass(Context, Class<?>) in the type Intent is not applicable for the arguments (GameV

    在当前短信内容的activity中写            Bundle bun = new Bundle();         bun.putString("message",  ...

  4. Lower dc/dc-converter ripple by using optimum capacitor hookup

    Low-ripple-voltage positive-to-negative dc/dc converters find use in many of today's high- frequency ...

  5. Appium+python自动化11-adb必知必会的几个指令

    前言 学android测试,adb是必学的,有几个常用的指令需要熟练掌握 一.检查设备 1.如何检查手机(或模拟器)是连上电脑的,在cmd输入: >adb devices

  6. setsockopt()用法(参数详细说明)

    int setsockopt(SOCKET s,int level,int optname,const char* optval,int optlen); s(套接字): 指向一个打开的套接口描述字l ...

  7. 《.NET最佳实践》

    <.NET最佳实践> 基本信息 原书名:Pro .NET Best Practices 原出版社: Apress 作者: (美)Stephen Ritchie 译者: 黄灯桥 黄浩宇 李永 ...

  8. JAVA常见算法题(三十一)---冒泡排序

    package com.jege.spring.boot.hello.world; /** * java算法之冒泡排序<br> * 将数组按照从大到小的顺序排列<br> * * ...

  9. python的单元测试框架

    1.unittest是Python内置的标准类库.它的API跟Java的JUnit..net的NUnit,C++的CppUnit很相似.   通过继承unittest.TestCase来创建一个测试用 ...

  10. C++内存管理学习堆和栈

    来源:http://c.chinaitlab.com/basic/936306_2.html 一 C++内存管理 1.内存分配方式 在讲解内存分配之前,首先,要了解程序在内存中都有什么区域,然后再详细 ...