zoukankan      html  css  js  c++  java
  • ADO之command

    connection      command对象使用的数据库连接

    commandText     执行的SQL语句

    ExecuteNonQuery  执行不返回行的语句,如UPDATE等

    ExecuteReader    返回DateReader对象

    ExecuteScalar    返回单个值,如执行COUNT(*)

    使用Command步骤

    1.创建数据库连接

    2.定义SQL语句

    3.创建Command对象

    4.执行命令

    sqlconnection connection = new sqlconnection(connstring);

    string sql = "select count(*) from Admin where loginid=' " + username +" ' and loginpwd=' " +pwd+" ' ";

    connection.open();//打开数据库连接

    sqlcommand command = new sqlcommand(sql,connection);

    int num = (int)command.ExecuteScalar();//要进行类型转换

  • 相关阅读:
    网页导出PDF文件
    图片翻转导航
    瀑布流之ajax
    楼梯效果
    数码时钟
    数字字母随机验证码
    kafka shell
    zookeeper shell
    正则
    Linux(一)
  • 原文地址:https://www.cnblogs.com/xiaomayizoe/p/5085816.html
Copyright © 2011-2022 走看看