Results 1 to 5 of 5

Thread: New to Database Development, How do u save a database?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 1999
    Posts
    77

    Post

    The subject mostly explains it, but I'll repeat myself, how do u save a database file or CREATE one?

    Justin

  2. #2
    New Member
    Join Date
    May 1999
    Location
    Indore,Madhya Pradesh, India
    Posts
    3

    Post

    If you use a DAO then the following will solve the purpose

    Dim dbname as database
    set dbname = createdatabase("path and the name of the database")

    This will create a MDB File and if you would like to open a database then

    dim dbname as database
    set dbname = opendatabase("Path to the database and the name")

    Hope this solves your query

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 1999
    Posts
    77

    Post

    Thx for the help. I did a little research on the syntax u gave me. I think I figured it out =]!

    Set database = workspace.CreateDatabase (name, locale, options)

    hehe

    Thx Again
    ,
    Justin =]

  4. #4
    New Member
    Join Date
    Jul 1999
    Posts
    3

    Post

    Try this code:
    Private Sub DBBackup()
    On Error Resume Next
    dbsCamp.Close
    Msg = ""
    On Error GoTo CompactErr
    OrigDBName = DBdir & "\Camp.mdb"
    Set dbsCamp = OpenDatabase(DBdir & "\Camp.mdb")
    'Show the properties of the original database.
    'Msg = "Properties of the current Data Base --> " & DBdir & "\camp.mdb database." & Chr(10)
    'With dbsCamp
    ' Msg = Msg & "Name=" & .Name & ", version " & .Version & Chr(10)
    ' Msg = Msg & " CollatingOrder = " & .CollatingOrder
    ' MsgBox Msg
    ' .Close
    'End With
    ' Make sure there isn't already a file with the
    ' name of the compacted database.
    For J = 1 To 50
    If Dir(DBdir & "\Campbkup" & J & ".mdb") = "" Then
    NewDBName = DBdir & "\Campbkup" & J & ".mdb"
    J = 50
    End If
    Next J
    If Dir(NewDBName) <> "" Then _
    Kill NewDBName
    dbsCamp.Close
    ' This statement creates a compact version of the
    ' Camp database called CampBkup.mdb
    DBEngine.CompactDatabase DBdir & "\Camp.mdb", _
    NewDBName, dbLangGeneral
    Set dbsCamp = OpenDatabase(NewDBName)
    Msg = "Properties of the your newly created Backup Data Base" & Chr(10)
    With dbsCamp
    Msg = Msg & "Name=" & .Name & ", version " & .Version & Chr(10)
    Msg = Msg & " CollatingOrder = " & .CollatingOrder
    End With
    MsgBox Msg & Chr(10) & "Data Base --> " & DBdir & "\camp.mdb successfully backed up " & Chr(10) _
    & "to file --> " & NewDBName & "."
    dbsCamp.Close
    Exit Sub
    CompactErr:
    If Err.Number <> 0 Then
    Msg = Msg & Chr(10)
    Msg = Msg & "Error # " & Str(Err.Number) & " was generated by " _
    & Err.Source & Chr(13) & Err.Description
    MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
    End If
    EOJ
    End Sub

  5. #5
    Addicted Member
    Join Date
    Oct 2000
    Location
    Orlando, FL
    Posts
    253
    How do I create a new database using ADO?
    Always looking for a better and faster way!

Posting Permissions

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



Click Here to Expand Forum to Full Width