Creating a database at run time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vdraceil
    New Member
    • Jul 2007
    • 236

    Creating a database at run time

    How do i create a database(.mdb) file at run time with a password?Any one please give me the code.Also,how am i supposed to access that file?-i know to open a .mdb file without a password.
  • 9815402440
    New Member
    • Oct 2007
    • 180

    #2
    hi

    simple way is to keep blank database for the purpose. when you need new database then copy it to the location where you want it. i dont know whether database can be cereated at runtime but tables can be created in an existing database. i can submit the code to create tables two or three days after today.

    regards
    manpreet singh dhillon hoshiarpur

    Comment

    • vdraceil
      New Member
      • Jul 2007
      • 236

      #3
      thanks for your reply..it'll be better if i have a code for it

      Comment

      • QVeen72
        Recognized Expert Top Contributor
        • Oct 2006
        • 1445

        #4
        Hi,

        Use DAO's to Create Database:

        Dim DB as Database
        Set DB = DBEngine.Create Database("C:\Ne wDb.mdb", dbLangGeneral)
        DB.NewPassword "", "MyPassword "


        Regards
        Veena

        Comment

        • vdraceil
          New Member
          • Jul 2007
          • 236

          #5
          Originally posted by QVeen72
          Hi,

          Use DAO's to Create Database:

          Dim DB as Database
          Set DB = DBEngine.Create Database("C:\Ne wDb.mdb", dbLangGeneral)
          DB.NewPassword "", "MyPassword "


          Regards
          Veena
          How to open that password protected database by code?

          Comment

          • debasisdas
            Recognized Expert Expert
            • Dec 2006
            • 8119

            #6
            Originally posted by vdraceil
            How to open that password protected database by code?
            pleae try this sample
            [code=vb]
            oConn.Open "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
            "Data Source=c:\somep ath\mydb.mdb;" & _
            "Jet OLEDB:Database Password=MyDbPa ssword", _
            "myUsername ", "myPassword "
            [/code]

            Comment

            • vdraceil
              New Member
              • Jul 2007
              • 236

              #7
              how do u create tables and fields by code??

              Comment

              • larystoy
                New Member
                • Nov 2007
                • 9

                #8
                Place a button on a form called "Command1"


                Dim DB As Database

                Private Sub Command1_Click( )

                '1) Create DataBase name "Names" using DAO
                Set DB = CreateDatabase( App.Path & "\Names", dbLangGeneral, dbEncrypt)

                '2) Create Tables and Fields (rename Table and fields as needed) using DAO
                ' and the Microsoft Jet SQL
                DB.Execute "CREATE TABLE Table1 " & "(First CHAR (50), Last CHAR (50), Age INT, Other Info NOTE);"

                '3) Create Password
                DB.NewPassword "", "MyPassword "


                DB.Close 'This Line is Optional
                MsgBox "DataBase Created."
                End
                End Sub

                Comment

                Working...