By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,593 Members | 2,006 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,593 IT Pros & Developers. It's quick & easy.

Creating a database at run time

vdraceil
100+
P: 236
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.
Dec 9 '07 #1
Share this Question
Share on Google+
7 Replies


9815402440
100+
P: 180
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
Dec 9 '07 #2

vdraceil
100+
P: 236
thanks for your reply..it'll be better if i have a code for it
Dec 11 '07 #3

QVeen72
Expert 100+
P: 1,445
Hi,

Use DAO's to Create Database:

Dim DB as Database
Set DB = DBEngine.CreateDatabase("C:\NewDb.mdb", dbLangGeneral)
DB.NewPassword "", "MyPassword"


Regards
Veena
Dec 11 '07 #4

vdraceil
100+
P: 236
Hi,

Use DAO's to Create Database:

Dim DB as Database
Set DB = DBEngine.CreateDatabase("C:\NewDb.mdb", dbLangGeneral)
DB.NewPassword "", "MyPassword"


Regards
Veena
How to open that password protected database by code?
Dec 11 '07 #5

debasisdas
Expert 5K+
P: 8,127
How to open that password protected database by code?
pleae try this sample
Expand|Select|Wrap|Line Numbers
  1. oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  2.            "Data Source=c:\somepath\mydb.mdb;" & _ 
  3.            "Jet OLEDB:Database Password=MyDbPassword", _
  4.            "myUsername", "myPassword"
  5.  
Dec 11 '07 #6

vdraceil
100+
P: 236
how do u create tables and fields by code??
Dec 16 '07 #7

P: 9
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
Jan 30 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.