第9章 操控数据库2精要.pptVIP

  • 1
  • 0
  • 约8.75千字
  • 约 42页
  • 2017-05-09 发布于湖北
  • 举报
第9章 操控数据库2精要

Command对象的常用方法 ExecuteReader 返回类型为SqlDataReader。用于用户进行的查询操作,返回查询结果。使用SqlDataReader对象的Read()方法进行逐行读取。 ExecuteNonQuery 执行一个非查询的SQL语句或存储过程,它的返回值类型为int型。多用于执行增加,删除,修改数据。返回受影响的行数。 ExecuteScalar 它的返回值类型多为int类型。该命令在集合查询中非常有用,如要统计某本书某天的销售量。 使用ExecuteReader( )方法 protected void btnqry_Click(object sender, EventArgs e) { string connstr = ConfigurationManager.ConnectionStrings[“nwconnstr].ConnectionString; string sql = select orderid, orderdate, shipaddress from orders + where customerid = + tbxuid.Text + ; using (SqlConnection conn = new SqlConnection(connstr)) { SqlCommand cmd = con

文档评论(0)

1亿VIP精品文档

相关文档