vb.net 如何对数据库查询结果记录集排序?
用如下查询:DimdrAsOleDbDataReaderDimconAsNewOleDbConnectionDimcmdAsNewOleDbCommandcon.Conn...
用如下查询:
Dim dr As OleDbDataReader
Dim con As New OleDbConnection
Dim cmd As New OleDbCommand
con.ConnectionString = MyConn_ConnectionString
con.Open()
cmd.Connection = con
cmd.CommandText = "select * from 信息表 where " & Sql & " Order by '编号' "
On Error Resume Next
dr = cmd.ExecuteReader()
结果查询记录集中的dr中的记录集,没有按编号字段排序,而是跟数据库原始表中的记录顺序一样的呢!
原来把
cmd.CommandText = "select * from 信息表 where " & Sql & " Order by '编号' "
写成
cmd.CommandText = "select * from 信息表 where " & Sql & " Order by 编号'"
即把排序编号的引号删除即可。 展开
Dim dr As OleDbDataReader
Dim con As New OleDbConnection
Dim cmd As New OleDbCommand
con.ConnectionString = MyConn_ConnectionString
con.Open()
cmd.Connection = con
cmd.CommandText = "select * from 信息表 where " & Sql & " Order by '编号' "
On Error Resume Next
dr = cmd.ExecuteReader()
结果查询记录集中的dr中的记录集,没有按编号字段排序,而是跟数据库原始表中的记录顺序一样的呢!
原来把
cmd.CommandText = "select * from 信息表 where " & Sql & " Order by '编号' "
写成
cmd.CommandText = "select * from 信息表 where " & Sql & " Order by 编号'"
即把排序编号的引号删除即可。 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询