|
-
Apr 16th, 2002, 11:40 AM
#1
Thread Starter
Fanatic Member
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 OLEDB atabase 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
-
Apr 16th, 2002, 11:54 AM
#2
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.
-
Apr 16th, 2002, 12:02 PM
#3
Hyperactive Member
Try This
Try this:
VB Code:
Dim NewDB As ADOX.Catalog
Set NewDB = New ADOX.Catalog
On Error GoTo Err_Exit
CreateDatabase = False 'Added here; If it fails, it will return false
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 'If it works, then it returns true
End If
Set NewDB = Nothing
Exit Function
Err_Exit:
CreateDatabase = False
Debug.Print "Error " & Err.Number, Err.Description
Err.Clear
Exit Function
Hope that helps
JazzBass
JazzBass
In the .NET era
Trying to remember VB6
Progress: 
XP Professional @ Home
and @ the Office
-
Apr 16th, 2002, 12:23 PM
#4
I think it's the after OLEDB.
-
Apr 16th, 2002, 12:25 PM
#5
Hyperactive Member
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
-
Apr 16th, 2002, 03:44 PM
#6
Thread Starter
Fanatic Member
oh errr it interpreted : then a D as
-
Apr 17th, 2002, 08:28 AM
#7
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|