SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    Non-Member XX7509's Avatar
    Join Date
    Feb 2003
    Location
    Antarctica
    Posts
    568
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    create access table with code?

    i want to create a program that uses an access database, but i want to create the database (mdb file) all the tables and fields with code... is there a way to do it? is there an article or sample or somthing on how to do it?

  2. #2
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can do this in Access with basic SQL statements like other databases, although, the exact syntax will vary from database to database.

    http://msdn.microsoft.com/library/de...able___sql.asp
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com

  3. #3
    Non-Member XX7509's Avatar
    Join Date
    Feb 2003
    Location
    Antarctica
    Posts
    568
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    [QUOTE='westmich']You can do this in Access with basic SQL statements like other databases, although, the exact syntax will vary from database to database.

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fox7help/html/lngcreate_table___sql.asp[/QUOTE]

    im making the program in vb.net would it still work?

  4. #4
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Westmich, the URL you quote is for FOXPro...

    Load up Access, go to Help, then click your way through the tree to:
    Code:
    Microsoft Jet SQL Reference -> Microsoft Jet SQL Reference -> Data Definition Language
    (that's the path in Access XP/2002 anyway)

    There you will find the full syntax of statements such as CREATE TABLE, which will allow you to do what you have asked...

    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  5. #5
    Non-Member XX7509's Avatar
    Join Date
    Feb 2003
    Location
    Antarctica
    Posts
    568
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by M@rco
    Load up Access, go to Help, then click your way through the tree to:
    Code:
    Microsoft Jet SQL Reference -> Microsoft Jet SQL Reference -> Data Definition Language
    (that's the path in Access XP/2002 anyway)

    There you will find the full syntax of statements such as CREATE TABLE, which will allow you to do what you have asked...

    [img]images/smilies/wink.gif[/img]
    thanks! I found the samples. I'm not sure I know enough about sql statements to understand it tho... I'm wondering if it might be easier for me to just create the table in access. I wanted to create it in code because I want to give the user some choice of what fields they want to use, so they can customize their program to thier needs. I created a few extra fields in an exzisting table called fldCustom1, fldCustom2 ... but it really dosen't give them the customize I want them to have.

    thanks for the help!

  6. #6
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,200
    Mentioned
    104 Post(s)
    Tagged
    1 Thread(s)
    Why don't you go to aspin.com and get one of the table editors there? There's one from eDevNetworx (I think that's what it's called) and there's one from a guy here that did one. You should be able to find one that does what you need.
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style

  7. #7
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not sure on the link - it was simply pointing to a create table SQL statement that I ran in Access so I know it works. In your code, you can have -

    Code:
    SQL = "
    Create Table myTable (
    myID INT Not Null,
    myField varchar(25) Nulll,
    )"
    and so on...

    For actual SQL reference, start here http://www.w3schools.com/sql/default.asp
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com


Bookmarks

Posting Permissions

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