<! -- # Include file = "../inc/md5.asp" -->
<%
'On Error Resume Next
Dbhost = request. Form ("dbhost ")
Dbname = request. Form ("dbname ")
Dbnew = request. Form ("dbnew ")
Dbuser = request. Form ("dbuser ")
Dbpw = request. Form ("dbpw ")
User_code = request. Form ("user_code ")
User_pwd = request. Form ("user_pwd ")
Formqian = request. Form ("formqian ")&"_"
Set conn = server. createobject ("adodb. connection ")
Connstr = "provider = sqloledb; data source =" & dbhost & "; User ID =" & dbuser & "; pwd =" & dbpw & "; Initial Catalog = master"
Conn. open connstr
If dbnew = "1" then
Conn.exe cute ("create database" & dbname & "ON (NAME = 'jxc _ dat ', FILENAME ='" & server. mappath (".. /data/"& dbname &". mdf ") &" ') log on (NAME = 'jxc _ log', FILENAME =' "& server. mappath (".. /data/"& dbname &" _ log. ldf ")&"')")
End if
If Err Then
Err. Clear
Set Conn = Nothing
%>
<Script language = "javascript">
Alert ("database connection failed. Please check database settings! ")
Window. history. go (-1)
</Script>
<%
Response. End
End If
If dbnew = "0" then
Conn.exe cute ("declare hcforeach cursor global for select 'Kill '+ rtrim (spid) from master. dbo. sysprocesses where dbid = db_id ('"& dbname &"') exec sp_msforeach_worker '? '")
End if
SQL = "use master Restore database" & dbname & "from disk = '" & server. mappath ("../data/start. dat") & "' with REPLACE"
Conn.exe cute (SQL)
Conn. close ()
Connstr = "provider = sqloledb; data source =" & dbhost & "; User ID =" & dbuser & "; pwd =" & dbpw & "; Initial Catalog =" & dbname
Conn. open connstr
Conn.exe cute ("update login set user_code = '" & user_code & "', user_pwd = '" & md5 (user_pwd )&"'")
Conn. close
Set conn = nothing
Set objfso = Server. CreateObject ("Scripting. FileSystemObject ")
Set fy = objfso. createtextfile (server. mappath ("../data/install. lock"), true)
Set fy = objfso. OpenTextFile (server. mappath ("../conn. asp"), 2)
Set fw = objfso. OpenTextFile (server. mappath ("conn.txt"), 1)
Tempconn2 = fw. Readall ()
Tempconn2 = replace (tempconn2, "{$ dbhost}", dbhost)
Tempconn2 = replace (tempconn2, "{$ dbname}", dbname)
Tempconn2 = replace (tempconn2, "{$ dbuser}", dbuser)
Tempconn2 = replace (tempconn2, "{$ dbpw}", dbpw)
Tempconn2 = replace (tempconn2, "{$ formqian}", formqian)
Fy. WriteLine (tempconn2)
%>
<Script type = "text/javascript"> document. getElementById ("laststep "). disabled = false; document. getElementById ("laststep "). value = 'installation successful, click Next '; </script>
<% End if %>
Refer to Jin mancang (WEB) Inventory Management System