Chức năng: Tạo CSLD Microsoft Access Database rổng
Ngôn ngữ: asp - Nhóm: database
CÚ PHÁP
MkDatabase pathname
Đối số pathname phải tồn tại, cần có tên database và phần mở rộng .mdb.
Hàm trả về false hoặc lổi nếu pathname không tồn tại hoặc tên db trùng với file đã có sẳn trong pathname.
Sử dụng lệnh FileDelete để xóa db.
VÍ DỤ
<%
MkDatabase "C:\database.mdb"
%>
ASP Code
<%
Private Sub MkDatabase(byVal pathname)
Dim objAccess, objFSO
If LCase( Right( pathname, 4 ) ) <> ".mdb" Then
Err.Raise 5155, "MkDatabase Statement", _
"Database name must end with '.mdb'"
Exit Sub
End If
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists( pathname ) Then
Set objFSO = Nothing
Err.Raise 5155, "MkDatabase Statement", _
"Specified MS Access database already exists."
Exit Sub
End If
Set objFSO = Nothing
On Error Resume Next
Set objAccess = CreateObject("Access.Application")
If Err Then
On Error GoTo 0
Err.Raise 5155, "MkDatabase Statement", _
"MS Access is not installed on this server."
Exit Sub
End If
With objAccess
.Echo False
.NewCurrentDatabase pathname
.CloseCurrentDatabase
.Quit
End With
Set objAccess = Nothing
On Error GoTo 0
End Sub
%>