ADOX中的CREATE只能建ACCESS库,我找了个建SQL SERVER库的


<%
'*********************************这是方法一
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 = server.CreateObject ("SQLDMO.LogFile")
With oLogFile
    .Name = sDatabaseName & "_log"
    .PhysicalName = sDatapath & "\" & sDatabaseName & "_log.ldf"
End With

' Add the DB File and Log file to the database object
oDatabase.FileGroups("PRIMARY").DBFiles.Add oDBFileData
oDatabase.TransactionLog.LogFiles.Add oLogFile

' Add the database to SQL Server (create the database)
oSQLServer.Databases.Add oDatabase

' Close the connection
oSQLServer.Close

' Clean Up
Set oLogFile = Nothing
Set oDBFileData = Nothing
Set oDatabase = Nothing
Set oSQLServer = Nothing
'**************************************方法二结束

本文作者:



相关阅读:
JQuery扩展插件Validate—4设置错误提示的样式
javascript跟随鼠标的文字带滚动效果
javascript 去字符串空格终极版(支持utf8)
js弹出层之1:JQuery.Boxy (二)
关于在FreeBSD上安装GD库的问题解决
SupeSite+X-Space+Discuz!打造资讯聚合站
JavaScript Timer实现代码
简介内容超出部分文字隐藏省略的特效(可显示)
遍历指定目录下的所有目录和文件的php代码
Chrome最新4.0版本支持GreaseMonkey脚本
DEDECMS网站被挂马的解决办法
教你一招配置Windows系统的页面文件
用javascript动态调整iframe高度的方法
vbs加administrator用户的代码
快速导航

Copyright © 2016 phpStudy | 皖ICP备18014864号-4