Right here goes I hope... I have a Friend sub I want to convert to a class? is there a way to do it? attached is the code incase there ahve to be some changes. I admit the code is not my own design, but have a use for ti as a class instead of a friend sub.
Treeviews and classes are new to me in VB.net as I'm still learning.
Friend Sub BindToTreeview(ByVal TableName As String, ByVal FieldName As String, ByVal tView As TreeView)
'Variables
Dim DbConn As ADODB.Connection
Dim DBPATH As String
DBPATH = AppPath & "Time.mdb"
'Connect To Database
Dim DbConnString As String
DbConnString = "Driver={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & DBPATH
'Open Database
DbConn = New ADODB.Connection
DbConn.ConnectionString = DbConnString
DbConn.Open()
'Create SQL
Dim SQL As String
SQL = "SELECT " & FieldName & " FROM " & TableName & ";"
'Create Recordset
Dim rSet As ADODB.Recordset
rSet = DbConn.Execute(SQL)
'Bind To Treeview
Dim tvItem As TreeNode
tvItem = New TreeNode
tvItem.Text = FieldName
While Not rSet.EOF
If rSet.Fields(0).ActualSize <> 0 Then tvItem.Nodes.Add(rSet.Fields(0).Value)
rSet.MoveNext()
End While
tView.Nodes.Add(tvItem)
'Close Database
DbConn.Close()
End Sub
Thanx a million
Treeviews and classes are new to me in VB.net as I'm still learning.
Friend Sub BindToTreeview(ByVal TableName As String, ByVal FieldName As String, ByVal tView As TreeView)
'Variables
Dim DbConn As ADODB.Connection
Dim DBPATH As String
DBPATH = AppPath & "Time.mdb"
'Connect To Database
Dim DbConnString As String
DbConnString = "Driver={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & DBPATH
'Open Database
DbConn = New ADODB.Connection
DbConn.ConnectionString = DbConnString
DbConn.Open()
'Create SQL
Dim SQL As String
SQL = "SELECT " & FieldName & " FROM " & TableName & ";"
'Create Recordset
Dim rSet As ADODB.Recordset
rSet = DbConn.Execute(SQL)
'Bind To Treeview
Dim tvItem As TreeNode
tvItem = New TreeNode
tvItem.Text = FieldName
While Not rSet.EOF
If rSet.Fields(0).ActualSize <> 0 Then tvItem.Nodes.Add(rSet.Fields(0).Value)
rSet.MoveNext()
End While
tView.Nodes.Add(tvItem)
'Close Database
DbConn.Close()
End Sub
Thanx a million