select top 3 昵称,商品,评论 from yourtab order by 你指明的前三条的条件 然后再绑定
SqlCommand cmd=new SqlCommand("select 昵称,商品,评论 from yourtab order by 你指明的前三条的条件",Conn);DataReader dr=dmd.ExecuteReader() if(dr.Read()) { //e 有记录的操作 } else { }
我想这样实现,用一个Repeater实现,在建立结果集的时候,有这样的代码: string sel = "select ware.wid,ware.wname ,sayword.unicknme,sayword.stitle,sayword.fen,sayword.sinsdate,sayword.sword from ware join sayword on ware.wid=sayword.wid"; DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(sel ,conn ); da.Fill (ds ,""); 最后一行中这个""中应该写什么表名呢
--create table Syohin (name char(10) not null,kind char(10) not null,note varchar(50) null) --insert into syohin values('摩托罗拉','1','aaaa') --insert into syohin values('摩托罗拉','1','aaaa') --insert into syohin values('诺基亚','2','bbbb') --insert into syohin values('诺基亚','2','bbbb') --insert into syohin values('索尼','3','cccc') --insert into syohin values('夏新','4','cccc') select top 3 name,kind from syohin group by kind,name 查询结果: -----------------------前三种商品---------------------- 1 摩托罗拉 2 诺基亚 3 索尼
然后再绑定啊
然后再绑定
if(dr.Read())
{
//e 有记录的操作
}
else
{
}
string sel = "select ware.wid,ware.wname ,sayword.unicknme,sayword.stitle,sayword.fen,sayword.sinsdate,sayword.sword from ware join sayword on ware.wid=sayword.wid"; DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(sel ,conn );
da.Fill (ds ,"");
最后一行中这个""中应该写什么表名呢
--insert into syohin values('摩托罗拉','1','aaaa')
--insert into syohin values('摩托罗拉','1','aaaa')
--insert into syohin values('诺基亚','2','bbbb')
--insert into syohin values('诺基亚','2','bbbb')
--insert into syohin values('索尼','3','cccc')
--insert into syohin values('夏新','4','cccc')
select top 3 name,kind from syohin group by kind,name
查询结果:
-----------------------前三种商品----------------------
1 摩托罗拉
2 诺基亚
3 索尼