Results 1 to 7 of 7

Thread: more database woes

Hybrid View

  1. #1

    Thread Starter
    Fanatic Member Gandalf_Grey_'s Avatar
    Join Date
    Oct 2001
    Location
    the 42nd dimension
    Posts
    665

    more database woes

    ok does anyone know waht is wrong with this function?

    Public Function CreateDatabase(DatabaseName As String, Optional Password As String = "") As Boolean

    Dim NewDB As ADOX.Catalog
    Set NewDB = New ADOX.Catalog

    On Error GoTo Err_Exit

    If Dir(DatabaseName, vbArchive + vbHidden + vbReadOnly + vbSystem) = "" Then

    NewDB.Create "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & Trim(DatabaseName) & _
    IIf(Password <> "", ";Jet OLEDBatabase Password=" & Password, "") & "; "
    CreateDatabase = True
    End If

    Set NewDB = Nothing
    CreateDatabase = True

    Exit Function
    Err_Exit:
    CreateDatabase = False
    Debug.Print "Error " & Err.Number, Err.Description
    Err.Clear
    Exit Function

    End Function

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Perhaps if you specify what's wrong, we could help? Some of us are too lazy to do a copy and paste and run that.

  3. #3
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393

    Smile Try This

    Try this:

    VB Code:
    1. Dim NewDB As ADOX.Catalog
    2. Set NewDB = New ADOX.Catalog
    3.  
    4. On Error GoTo Err_Exit
    5.  
    6. CreateDatabase = False 'Added here; If it fails, it will return false
    7.  
    8. If Dir(DatabaseName, vbArchive + vbHidden + vbReadOnly + vbSystem) = "" Then
    9.  
    10. NewDB.Create "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & Trim(DatabaseName) & _
    11. IIf(Password <> "", ";Jet OLEDBatabase Password=" & Password, "") & "; "
    12. CreateDatabase = True 'If it works, then it returns true
    13. End If
    14.  
    15. Set NewDB = Nothing
    16.  
    17.  
    18. Exit Function
    19. Err_Exit:
    20. CreateDatabase = False
    21. Debug.Print "Error " & Err.Number, Err.Description
    22. Err.Clear
    23. Exit Function

    Hope that helps

    JazzBass
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I think it's the after OLEDB.

  5. #5
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393

    Smile I did try the code

    Gandalf,

    I did forget to tell you I tried your code and it worked. I only added the lines that are marked by comments.

    Hope that helps,
    JazzBass
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

  6. #6

    Thread Starter
    Fanatic Member Gandalf_Grey_'s Avatar
    Join Date
    Oct 2001
    Location
    the 42nd dimension
    Posts
    665
    oh errr it interpreted : then a D as

  7. #7
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393

    Smile Gandalf_Grey_

    Forgive me for being a little slow, but did you figure it out?

    JazzBass
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

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