Results 1 to 2 of 2

Thread: how to add a table?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Posts
    28

    how to add a table?

    I am writing a VB app. I want to create a table and add some records in it. How can I do this? I also want to know how to get the data from that table.

    Thanks alot.

  2. #2
    Megatron
    Guest
    If you are using DAO, try something like:
    VB Code:
    1. Dim db As DAO.Database
    2. Dim tbl As DAO.TableDef
    3. Dim fld As Field
    4.  
    5. Set db = OpenDatabase("MyDB.mdb")
    6.  
    7. Set fld = New Field
    8. fld.Name = "Name"
    9. fld.Type = dbText
    10. fld.FieldSize = 20
    11. tbl.Fields.Append fld
    12.  
    13. Set fld = New Field
    14. fld.Name = "ID"
    15. fld.Type = dbText
    16. fld.FieldSize = 10
    17. tbl.Fields.Append fld
    18.  
    19. db.TableDefs.Append tbl

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