ADOX中的CREATE只能建ACCE库,我找了个建SQL SERVER库的_SQL SERVER数据库_黑客防线网安服务器维护基地--Powered by WWW.RONGSEN.COM.CN

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

作者:黑客防线网安SQL维护基地 来源:黑客防线网安SQL维护基地 浏览次数:0

本篇关键词:只能&
黑客防线网安网讯:<%'*********************************这是方法一Dim oConn Dim sDatabaseName sDatabaseName = "test1"set oconn=server.CreateObject ("adodb.connection")oConn.Open "Provider=SQLO...

<%
'*********************************这是方法一
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 FilesMicrosoft SQL ServerMSSQLData"


' 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
'**************************************方法二结束

    黑客防线网安服务器维护方案本篇连接:http://www.rongsen.com.cn/show-10181-1.html
网站维护教程更新时间:2012-03-21 02:30:27  【打印此页】  【关闭
我要申请本站N点 | 黑客防线官网 |  
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479

footer  footer  footer  footer