<%
'*********************************這是方法一
Dim oConn
Dim sDatabaseName
sDatabaseName = "test1"
set oconn=server.CreateObject ("adodb.connection")
oConn.Open "Provider=SQLOLEDB;Data Source=you_server;User ID=sa;Password=you_sa_passWord;"
oConn.Execute "CREATE DATABASE " & sDatabaseName
oConn.Close
set oconn=nothing
'*********************************方法一結束
'*********************************這是方法二
Dim oSQLServer
Dim oDatabase
Dim oDBFileData
Dim oLogFile
Dim sDatabaseName
Dim sDatapath
sDatabaseName = "test1"
'下面改成你的SQL Server數據目錄
sDatapath = "C:\Program Files\Microsoft SQL Server\MSSQL\Data"
' Create a new SQL Server object and connect
Set oSQLServer = server.CreateObject ("SQLDMO.SQLServer")
' oSQLServer.LoginSecure = True
' Use integrated security
' oSQLServer.Connect "(local)"
oSQLServer.Connect "you_server", "sa", "you_sa_passwrod" ' Use standard security
' Create a server.CreateObject (" Database object
Set oDatabase = server.CreateObject ("SQLDMO.Database")
oDatabase.Name = sDatabaseName
' Create a server.CreateObject (" DB File object
Set oDBFileData = server.CreateObject ("SQLDMO.DBFile")
With oDBFileData
.Name = sDatabaseName & "_data"
.PhysicalName = sDatapath & "\" & sDatabaseName & "_data.mdf"
.PrimaryFile = True
.FileGrowthType = SQLDMOGrowth_MB
.FileGrowth = 1
End With
' Create a server.CreateObject (" LogFile object
Set oLogFile = ser