Murray Brown
asked on
VB.net Create .accde file on a machine that doesn't have Access
Hi
I am using the following VB.net code in my Excel Add-in to create an Access
database. Certain of the users of my app will not have Access on their machines.
Will this sort of code be able to create a .accde file?
Public Sub Create_Access()
Dim P As String = "C:\Users\murbro\Documents \TestDB.ac cdb"
If CreateAccessDatabase(P) = True Then
MsgBox("Database Created")
Else
MsgBox("Database Creation Failed")
End If
End Sub
Public Function CreateAccessDatabase( _
ByVal DatabaseFullPath As String) As Boolean
Dim bAns As Boolean
Dim cat As New ADOX.Catalog()
Try
'Make sure the folder
'provided in the path exists. If file name w/o path
'is specified, the database will be created in your
'application folder.
Dim sCreateString As String
sCreateString = _
"Provider=Microsoft.Jet.OL EDB.4.0;Da ta Source=" & _
DatabaseFullPath
cat.Create(sCreateString)
bAns = True
Catch Excep As System.Runtime.InteropServ ices.COMEx ception
bAns = False
'do whatever else you need to do here, log,
'msgbox etc.
Finally
cat = Nothing
End Try
Return bAns
End Function
I am using the following VB.net code in my Excel Add-in to create an Access
database. Certain of the users of my app will not have Access on their machines.
Will this sort of code be able to create a .accde file?
Public Sub Create_Access()
Dim P As String = "C:\Users\murbro\Documents
If CreateAccessDatabase(P) = True Then
MsgBox("Database Created")
Else
MsgBox("Database Creation Failed")
End If
End Sub
Public Function CreateAccessDatabase( _
ByVal DatabaseFullPath As String) As Boolean
Dim bAns As Boolean
Dim cat As New ADOX.Catalog()
Try
'Make sure the folder
'provided in the path exists. If file name w/o path
'is specified, the database will be created in your
'application folder.
Dim sCreateString As String
sCreateString = _
"Provider=Microsoft.Jet.OL
DatabaseFullPath
cat.Create(sCreateString)
bAns = True
Catch Excep As System.Runtime.InteropServ
bAns = False
'do whatever else you need to do here, log,
'msgbox etc.
Finally
cat = Nothing
End Try
Return bAns
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER