[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 140
  • Last Modified:

How to create a database

1. How to create & Open a database with database password
   in Jet Database ( Using ADO)

2. How to create & Open a database with database password
   in SQL-Server ( Using ADO)

thanks in advance

0
ackid32
Asked:
ackid32
  • 3
  • 2
1 Solution
 
jayeshshahCommented:
1.
for Creating Databases in Access you can use ADOX as shown below

Dim Cat As New ADOX.Catalog        
Cat.Create "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & Str_Path '' (where database has to be made)
Cat.ActiveConnection.Close

for using the above code you have to add an reference to Microsoft ADO Ext. 2.1 for DDL and Security.

2.
For SQL Server below is the code
Dim Cn as new Adodb.Connection
Cn.Connectionstring = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;pwd=;Data Source=" & SQL Server Name.
cn.open

cn.execute "Create database " &  new database name

0
 
ackid32Author Commented:
dear jayesh

i know how to create these databases but not with DATABASE PASSWORD

i want that.
0
 
jayeshshahCommented:
try putting the password field in the Create statement.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
hongjunCommented:
0
 
hongjunCommented:
sorry CreateDatabase is not a sql syntax!!! It is a method!

hongjun
0
 
hongjunCommented:
http://www.mvps.org/access/modules/mdl0036.htm

************* Code Start *****************
Function foo()
   Dim db As Database
   Dim oAcc As Access.Application

   Const TMP = "fooz.mdb"

   Set db = DBEngine.CreateDatabase(TMP, _
                       dbLangGeneral)
   db.NewPassword "", "doooo"
   db.Close
   Set db = Nothing

   Set oAcc = New Access.Application
   Set db = oAcc.DBEngine.OpenDatabase(TMP, _
                           False, False, ";PWD=doooo")
   oAcc.OpenCurrentDatabase TMP
   db.Close
   Set db = Nothing
End Function


hongjun
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now