SQL Server: Create Database <DbName>
Access: VB6.0 code:
Function CreateDatabaseX(ByVal Fn As String) As Integer
'Create an Access database function,
'Return value:
' 0 - Successfully
' 1 - File already exist
' 2 - Workspace create error Dim wrkDefault As Workspace
Dim dbsNew As Database
Dim prpLoop As Property
' Get default Workspace.
Set wrkDefault = DBEngine.Workspaces(0) ' Make sure there isn't already a file with the name of
' the new database.
If Dir(Fn) <> "" Then
CreateDatabaseX = 1
Exit Function
End If
' Create a new encrypted database with the specified
' collating order.
On Error GoTo CreateError
Set dbsNew = wrkDefault.CreateDatabase(Fn, _
dbLangGeneral, dbEncrypt)
CreateDatabaseX = 0
dbsNew.Close
Exit Function
CreateError:
CreateDatabaseX = 2
End Function
实际上这些东西在MSDN上都有。
Access: VB6.0 code:
Function CreateDatabaseX(ByVal Fn As String) As Integer
'Create an Access database function,
'Return value:
' 0 - Successfully
' 1 - File already exist
' 2 - Workspace create error Dim wrkDefault As Workspace
Dim dbsNew As Database
Dim prpLoop As Property
' Get default Workspace.
Set wrkDefault = DBEngine.Workspaces(0) ' Make sure there isn't already a file with the name of
' the new database.
If Dir(Fn) <> "" Then
CreateDatabaseX = 1
Exit Function
End If
' Create a new encrypted database with the specified
' collating order.
On Error GoTo CreateError
Set dbsNew = wrkDefault.CreateDatabase(Fn, _
dbLangGeneral, dbEncrypt)
CreateDatabaseX = 0
dbsNew.Close
Exit Function
CreateError:
CreateDatabaseX = 2
End Function
实际上这些东西在MSDN上都有。
能不能用ado来实现啊?
用sql语句建立数据库“create database”,然后用connection.execute,或者command提交不就行了
尤其是对access要凭空生成mdb文件,怎么做啊?