在ASP 中使用 SQL_DMO 添加新数据库
类别: ASP教程
set oSQLServer =server.createobject("SQLDMO.SQLServer")
oSQLServer.Connect "数据库IP,端口","用户名","密码" \' 连接数据库
set oSQLServer =server.createobject("SQLDMO.Database")
set oDBFileData =server.createobject("SQLDMO.DBFile")
set oLogFile =server.createobject("SQLDMO.LogFile")
oDatabase.Name = "test"
oDBFileData.Name = "test1"
oDBFileData.PhysicalName = "c:program filesmicrosoft sql servermssqldatatest.mdf"
oDBFileData.PrimaryFile = True
oDBFileData.FileGrowthType = SQLDMOGrowth_MB
oDBFileData.FileGrowth = 1
oDatabase.FileGroups("PRIMARY").DBFiles.Add oDBFileData
oLogFile.Name = "test1"
oLogFile.PhysicalName = "c:program filesmicrosoft sql servermssqldatatest.ldf"
oDatabase.TransactionLog.LogFiles.Add oLogFile
oSQLServer.Databases.Add oDatabase
oSQLServer.Connect "数据库IP,端口","用户名","密码" \' 连接数据库
set oSQLServer =server.createobject("SQLDMO.Database")
set oDBFileData =server.createobject("SQLDMO.DBFile")
set oLogFile =server.createobject("SQLDMO.LogFile")
oDatabase.Name = "test"
oDBFileData.Name = "test1"
oDBFileData.PhysicalName = "c:program filesmicrosoft sql servermssqldatatest.mdf"
oDBFileData.PrimaryFile = True
oDBFileData.FileGrowthType = SQLDMOGrowth_MB
oDBFileData.FileGrowth = 1
oDatabase.FileGroups("PRIMARY").DBFiles.Add oDBFileData
oLogFile.Name = "test1"
oLogFile.PhysicalName = "c:program filesmicrosoft sql servermssqldatatest.ldf"
oDatabase.TransactionLog.LogFiles.Add oLogFile
oSQLServer.Databases.Add oDatabase
- 上一篇: 一些初学都常用的ASP代码
- 下一篇: 在ASP 中使用 SQL_DMO 给表添加索引
-= 资 源 教 程 =-
文 章 搜 索