Results 1 to 27 of 27

Thread: [RESOLVED] Loading from DB into array / treeview

Threaded View

  1. #1

    Thread Starter
    Frenzied Member aikidokid's Avatar
    Join Date
    Aug 2002
    Location
    Bristol, UK
    Posts
    1,968

    Resolved [RESOLVED] Loading from DB into array / treeview

    I am completely new to Access and Databases (and limited ability with VB6 as well) but don't let that put you off.

    I am using VB6 and Access 2002

    I have downloaded the tutorial suggested in the FAQ's and run it in a practise project and got it all to work as should be.

    I have now tried to put this code into my project, which is making a Code Library for myself.

    The first thing I am trying to accomplish is to load the list in the attached image under the title tvwNodes into an array, to then use to name the Nodes in my treeview (tvwCode)

    I have the following code where I get an error after all the 6 records have been added to the array
    "Run-time error 94"
    "Invalid use of Null"
    My code is:

    vb Code:
    1. 'declare it as a ADO-DB
    2. Set cn = New ADODB.Connection
    3.  
    4. 'set the connection
    5. cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    6. "Data Source=C:\Documents and Settings\Andrew\My Documents\VB6\New Code Library\DBCL.mdb"
    7. cn.Open
    8. Set rs = New ADODB.Recordset
    9. rs.Open "tbl_Nodes", cn, adOpenKeyset, adLockPessimistic, adCmdTable
    10.  
    11. 'move to first record
    12. rs.MoveFirst
    13. 'loop to add items to array
    14. ReDim tvw_Nodes(0)
    15. Do Until rs.EOF = True
    16.     tvw_Nodes(UBound(tvw_Nodes)) = rs.Fields("tvwNodes")
    17.     Debug.Print tvw_Nodes(UBound(tvw_Nodes))
    18.     rs.MoveNext
    19.     ReDim Preserve tvw_Nodes(UBound(tvw_Nodes) = 1)
    20. Loop

    Could this be because the list in the second field is longer?
    I wouldn't have thought so, but as I said in my first line of this thread ...
    Quote Originally Posted by Me
    I am completely new to Access and Databases
    Attached Files Attached Files
    Last edited by aikidokid; Mar 10th, 2007 at 09:43 AM. Reason: better describes what is answered below
    If somebody helps you, take time to RATE the post. I do.

    "FAILURE IS NOT AN OPTION. It comes bundled with the software."

    Below are some of the threads that have helped me along the way:

    CodeBank submission:
    Listview Backcolor (without subclassing)

    Loading Treeview Nodes From A Database, Creating Registry Keys, Count Number of Lines in TextBox , Excellent RichTextBox Tricks & Tips
    Ideas & Screen Shots For A Code Library App
    How to do Data validation in Excel, Conditional Formating in Excel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width