当前位置: 代码迷 >> VB Dotnet >> access 读取数据的顺序是什么,该怎么解决
  详细解决方案

access 读取数据的顺序是什么,该怎么解决

热度:281   发布时间:2016-04-25 02:00:33.0
access 读取数据的顺序是什么
本帖最后由 yinbiankcd 于 2015-09-13 17:59:27 编辑


例如上图  它是按照ID从1往下读还是怎么 我怎么发现好像不是
我把一列数据取出来放在一个datatable里
然后循环读取
  Dim con As New OleDb.OleDbConnection
        Dim cmdn As New OleDb.OleDbCommand
        con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\wq\Desktop\实例.accdb;Persist Security Info=False"
        cmdn.Connection = con
        Dim aql As String
        aql = "Select  W1 from treeview"
        cmdn.CommandText = aql
        con.Open()
        Dim dan As New OleDb.OleDbDataAdapter
        dan.SelectCommand = cmdn
        Dim dsn As New DataSet
        dan.Fill(dsn)
        Dim dtn As DataTable = dsn.Tables(0)
        Dim num As Integer
        num = dtn.Rows.Count
        Dim wellname(num - 1) As String
        Dim ii As Integer = 0
        For i = 0 To num - 1
            If Not IsDBNull(dtn.Rows(i).Item(0)) Then
                wellname(i) = dtn.Rows(i).Item(0)
            End If
        Next
        con.Close()
        TextBox1.Text = wellname(0)
        TextBox2.Text = wellname(1)
        TextBox3.Text = wellname(2)
        TextBox4.Text = wellname(3)
        TextBox5.Text = wellname(4)
        TextBox6.Text = wellname(5)
        TextBox7.Text = wellname(6)
        TextBox8.Text = wellname(7)
如果想让他从上往下读 应该加些什么代码
我试了试 顺序没有一点规律文本框的排序是从左到右12345  第二行是678   顺序都照应

------解决思路----------------------
发完居然发现你修改了
aql = "Select  W1 from treeview order by ID"
  相关解决方案