Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Creating Access Database using Code

Creating Access Database using Code

Scheduled Pinned Locked Moved Visual Basic
databasequestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vister72
    wrote on last edited by
    #1

    Hello, Is there a way to create an entire Access database (I know what tables and the relationships needed between the tables) using VB code? For instance, if a user clicked on a "Create Plan" icon, the following database would be created in the back end: Database: Census Tables: Client Plan Employees Contacts If you know of references you could direct me to in order to learn more about this, it would be greatly appreciated. Thanks so much! Vi

    M 1 Reply Last reply
    0
    • V vister72

      Hello, Is there a way to create an entire Access database (I know what tables and the relationships needed between the tables) using VB code? For instance, if a user clicked on a "Create Plan" icon, the following database would be created in the back end: Database: Census Tables: Client Plan Employees Contacts If you know of references you could direct me to in order to learn more about this, it would be greatly appreciated. Thanks so much! Vi

      M Offline
      M Offline
      Mike Ellison
      wrote on last edited by
      #2

      There are ways to do this. Are you using VB6 or .NET?

      V 1 Reply Last reply
      0
      • M Mike Ellison

        There are ways to do this. Are you using VB6 or .NET?

        V Offline
        V Offline
        vister72
        wrote on last edited by
        #3

        Hi Mike, I forgot to mention that I'm using VB.net . I'm a new user and have just gone through my first book Visual Basic.Net Step by Step. I'm trying to create a utility for use at work and have no idea where to begin. Any ideas / help would be greatly appreciated. Thanks so much! Vi

        M 1 Reply Last reply
        0
        • V vister72

          Hi Mike, I forgot to mention that I'm using VB.net . I'm a new user and have just gone through my first book Visual Basic.Net Step by Step. I'm trying to create a utility for use at work and have no idea where to begin. Any ideas / help would be greatly appreciated. Thanks so much! Vi

          M Offline
          M Offline
          Mike Ellison
          wrote on last edited by
          #4

          Hi Vi. You know, most beginners start with "Hello World" instead of "Create Access Database from Scratch" :-D One way to accomplish what you're describing is through the ADOX library. Here's a link to MSDN documentation introducing ADOX: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/admscadoxfundamentals.asp[^] In a nutshell, the ADOX Catalog object's Create() method will let you create the .mdb file. Then you can use a standard ADO.NET OleDbConnection object to connect to the new database file, and an ADO.NET OleDbCommand object to execute sql statements against the connection. Using OleDbCommand's ExecuteNonQuery() method will let you issue statements like "Create Table xxx ..." to create your tables. Alternatively, you could use ADOX's Table object to accomplish the same task. ADOX is a COM library, not a .NET library, meaning that you have to use Interop techniques to use the ADOX objects in your .NET code. This isn't difficult, and there are many articles available on the subject of COM Interop. This article shows an example of using Visual Studio to make the proper references to the COM ADOX library: http://www.tek-tips.com/gfaqs.cfm/lev2/4/lev3/32/pid/796/fid/3888[^] This article (right here on CodeProject) goes more in depth into the concept of Interop. Its fairly long, but toward the bottom are ADOX examples that are directly relevant to the task you're working on - http://codeproject.com/books/186100558x_16.asp[^] I hope this gives you something you can work with. --mike

          V 1 Reply Last reply
          0
          • M Mike Ellison

            Hi Vi. You know, most beginners start with "Hello World" instead of "Create Access Database from Scratch" :-D One way to accomplish what you're describing is through the ADOX library. Here's a link to MSDN documentation introducing ADOX: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/admscadoxfundamentals.asp[^] In a nutshell, the ADOX Catalog object's Create() method will let you create the .mdb file. Then you can use a standard ADO.NET OleDbConnection object to connect to the new database file, and an ADO.NET OleDbCommand object to execute sql statements against the connection. Using OleDbCommand's ExecuteNonQuery() method will let you issue statements like "Create Table xxx ..." to create your tables. Alternatively, you could use ADOX's Table object to accomplish the same task. ADOX is a COM library, not a .NET library, meaning that you have to use Interop techniques to use the ADOX objects in your .NET code. This isn't difficult, and there are many articles available on the subject of COM Interop. This article shows an example of using Visual Studio to make the proper references to the COM ADOX library: http://www.tek-tips.com/gfaqs.cfm/lev2/4/lev3/32/pid/796/fid/3888[^] This article (right here on CodeProject) goes more in depth into the concept of Interop. Its fairly long, but toward the bottom are ADOX examples that are directly relevant to the task you're working on - http://codeproject.com/books/186100558x_16.asp[^] I hope this gives you something you can work with. --mike

            V Offline
            V Offline
            vister72
            wrote on last edited by
            #5

            Excellent! Thank you so much Mike for taking the time to post this. I will most definitely do some digging. :)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups