检索数据库中项目的名称以便在treeview对象中使用?

时间:2014-05-13 17:25:48

标签: vb.net treeview nodes names

我有代码用父节点填充树视图对象。问题是我不确定如何获取名称以反映它们在数据库中的位置(微软访问数据库)。我正在使用vb.net如果有帮助,这是我到目前为止的代码

Imports System.Data
Imports System.Data.OleDb
Imports System.Data.SqlClient

Public Class Form1
    Dim mypath = "I:\Casegoods\Database\Expertpetrolia.mdb"
    Dim conn As New OleDbConnection("Provider = microsoft.ace.oledb.12.0;Data Source=" & mypath)
    Dim cmd As OleDbCommand
    Dim da As New OleDbDataAdapter
    Dim ds As New DataSet
    Dim dr As OleDbDataReader
    Dim maxrows As Integer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Dim sql1 = "SELECT Due_Date FROM Supply_Date;"
    Dim cmd As OleDbCommand
    Using conn
        cmd = New OleDbCommand(sql1, conn)
        conn.Open()

        dr = cmd.ExecuteReader
        If dr.HasRows Then
            Do While dr.Read()
                TreeView1.Nodes.Add('text to name them goes here, what can i use?)
            Loop
        Else
            MsgBox("No Things found")
        End If

        dr.Close()
    End Using

    End Sub
End Class

任何帮助将不胜感激!

0 个答案:

没有答案