absent Posted November 6, 2003 Posted November 6, 2003 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 Quote P.L.U.R - Peace, Love, Unity, Respect :P
Moderators Robby Posted November 6, 2003 Moderators Posted November 6, 2003 Before conerting it to a class perhaps get it converted to ADO.NET. Quote Visit...Bassic Software
absent Posted November 6, 2003 Author Posted November 6, 2003 why would I need to convert it to ADO.net? all I'm really wanting to do is create a reusable bind to tree function to bind a few treeviews in an app I'm writing... I'm still new to vb.net so still hazy on why and how to do things Quote P.L.U.R - Peace, Love, Unity, Respect :P
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.