ASP安装SQL数据库和导入数据和建立用户

作者:袖梨 2022-06-30
<%
'on error resume next
action=request("action")
IF action<>"install" THEN
%>




填写安装信息


SQL数据库管理员:

SQL数据库密 码:

SQL数据库地 址:





<%
Else
StrUid=request("StrUid")
StrSaPwd=request("StrSaPwd")
StrServer=request("StrServer")
call CreateDB("info")
call RestoreDB("info","backup1.bak")
call CreateUser("bin","85228522","info")
response.write "


"
End if
'step1 建立数据库
Sub CreateDB(StrDBName)
Dim Conn '数据库连接
Dim StrDSN '数据库连接字符串
Dim StrCmd '命令字符串
StrDSN="driver={SQL server};server="&StrServer&";uid="&StrUid&";pwd="&StrSaPwd&";database=master"
'建立和数据库master的连接
set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open StrDSN
'新建一数据库
StrCmd="CREATE DATABASE "&StrDBName
Conn.execute(StrCmd)
Conn.Close
Set Conn=Nothing
End Sub
'step2 导入数据
sub RestoreDB(StrDBName,fromBak)
SQL="Restore database " & StrDBName & " from disk='"&Server.MapPath(fromBak)&"'"

相关文章

精彩推荐