留言与评论(共有 0 条评论) |
发布时间:2020-04-12 08:39:46
executenonquery这个返回的影响的行数.你查询当然是没有影响的行.只有添加/修改/删除才会有结果的你查询用这个..this.textbox1.text=mycmd.executescalar().tostring();
sql中查询记录数用count函数。
1、创建测试表,插入数据:
create table test(id int)insert into test values (1)insert into test values (2)insert into test values (3)insert into test values (null)
2、查询记录数为两种,一种是count(*),一种是count(字段值):
测试一:
select count(*) from test
结果:
测试二:
select count(id) from test
结果:
说明:如果count(字段名)的字段中含有空值,则在count中不计数,而count(*)则是查询全部的行数。
留言与评论(共有 0 条评论) |
全站搜索