Results 1 to 6 of 6

Thread: DataBase RESOLVED

  1. #1

    Thread Starter
    Hyperactive Member Blacknight's Avatar
    Join Date
    Nov 2002
    Posts
    381

    DataBase RESOLVED

    VB Code:
    1. dim a as adodb.recordset
    2. Dim usersDB As ADODB.Connection
    3.  
    4. Private Sub Form_Load()
    5. Set usersDB = New ADODB.Connection
    6. usersDB.Open "dsn=DATABASENAME;"
    7.  
    8. Set a = New ADODB.Recordset
    9. usersDB.Execute ("update FIELDNAME where)
    10. 'a.fields(number) I know that this line gives me the value of the
    11. 'field however i don't know how i can find the field's name
    12. 'lets say that i want to print all of my table's fieldls' names
    13. 'in a loop How can i do this? i want to use it to update many cells
    14. 'as shown above (FIELDNAME)

    Thank you,
    Blacknight
    Last edited by Blacknight; Mar 11th, 2004 at 10:40 AM.

  2. #2
    Frenzied Member
    Join Date
    May 2003
    Location
    So Cal
    Posts
    1,564

    Re: DataBase

    Hard to see your actual question when you use it as remarks in your code.

  3. #3

    Thread Starter
    Hyperactive Member Blacknight's Avatar
    Join Date
    Nov 2002
    Posts
    381
    lol, just want to know how i can print in a loop all my table fields' names

  4. #4
    Fanatic Member demotivater's Avatar
    Join Date
    Jun 2002
    Location
    is everything
    Posts
    627
    This loads the db field names into a treeview - you can modify it to suit your needs. targetDB in the cn.Open line would be the name of your database.

    VB Code:
    1. ' Clear the TreeView.
    2.     trvTarget.Nodes.Clear
    3.     'open connection
    4.     cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & targetDB & ";Persist Security Info=False"
    5.     'set recordset to database schema
    6.     Set rs = cn.OpenSchema(adSchemaTables, Array(Empty, Empty, Empty, "Table"))
    7.     'loop through recordset and list all tables in the treeview
    8.     Do While Not rs.EOF
    9.         Set table_node = trvTarget.Nodes.Add(, , , _
    10.             rs!TABLE_NAME)
    11.         table_node.Tag = "Table"
    12.         rs.MoveNext
    13.     Loop

  5. #5

    Thread Starter
    Hyperactive Member Blacknight's Avatar
    Join Date
    Nov 2002
    Posts
    381
    what is trvTarget?

    is that a recordset?
    also i am not sure you understood what i want; i want to print all field names in a specific table, not all my table's names

  6. #6

    Thread Starter
    Hyperactive Member Blacknight's Avatar
    Join Date
    Nov 2002
    Posts
    381
    never mind, problem solved!
    i just write recordset.fields(number).name

    thank you

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