asp下自動安裝資料庫

來源:互聯網
上載者:User

<!-- #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.execute("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("資料庫連接失敗,請檢查資料庫設定!")
window.history.go(-1)
</script>
<%
  Response.End
End If

if dbnew="0" then
conn.execute("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.execute(sql)
conn.close()

connstr="provider=sqloledb;data source="&dbhost&";User ID="&dbuser&";pwd="&dbpw&";Initial Catalog="&dbname
conn.open connstr
conn.execute("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 = '安裝成功,點擊進入下一步';</script>
<%end if%>

 

參考  《金滿倉(WEB)進銷存管理系統》

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.