<% 'on error resume next action=request("action") IF action<>"install" THEN %> <BR> <center> <form method="POST" action="install.asp?action=install" name="form1"> 填写安装信息<BR><BR> SQL数据库管理员:<input name=StrUid value=sa><BR> SQL数据库密 码:<input name=StrSaPwd value=40104529><BR> SQL数据库地 址:<input name=StrServer value=localhost><BR><BR> <input name="cmdok" type="submit" class="form1" value="开始安装..." > </form> </center> <% 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 "<center><br><BR><input type='button' value='安装完成!' onclick='javascript:windows.close()'></center>" 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)&"'" |