zoukankan      html  css  js  c++  java
  • 数据库课程设计心得【2】SqlCommand.Parameter属性

    SqlCommand.Parameter属性的作用是利用参数化的方法来调用T-SQL语句或者存储过程,它相较于传统的字符串拼接的优势是明显的:(1)可以减少诸如string Strsql = "select * from CM_Users where CM_User_id='" + nid + "' and CM_User_password='" + pwd + "'";的运用,代码可读性高;(2)可以在一定程度上防范SQL注入,安全性高。

     

    SqlCommand.Parameter属性的add()方法的作用是:添加参数到SqlParameterCollection 参数集,add里面的第一个参数是要添加的参数名,第二个参数是参数的数据类型。举两个例子如下:

    例1:

    例2:

  • 相关阅读:
    Linux 中国镜像
    VMWare 安装 Debian 9
    Linux 安装Docker compose 快速方法
    Nginx on Docker 配置
    Docker 中配置Nginx
    Nginx IPV4 问题
    VMWare中CentOS 7 配置 XShell连接
    在CentOS 7 中安装Docker
    Docker for Windows 和虚拟机VMWare共存方案
    Nginx 配置多个站点
  • 原文地址:https://www.cnblogs.com/javaadu/p/11742803.html
Copyright © 2011-2022 走看看