海外邮件中继,海外退信中继,美国高速VPS,不限流量VPN,邮局维护和管理,邮件网关,EMOS邮件中继,POSTFIX邮件中继,Winwebmail邮件中继,Winmail邮件中继,DBMail邮件中继,JDMail邮件中继,Exchange邮件中继,MDaemon邮件中继 淘宝店:http://shantan.taobao.com 云邮科技官网:www.yunrelay.com
【字体设置:大 中 小】
复制数据库中相关字段的ASP代码
前段时间,看到了“netpatch”所介绍的“新型ASP木马”,于是借鉴代码写出了一个可以复制字段的ASP文件,这个文件适用于复制大型的数据库,尤其是SQL数据库中的部分关键字段。代码如下:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>数据库字段复制工具</title>
<style type="text/css">
<!--
body,td,tr,table,form,option,select,main,input,textarea,p
{font-size: 12px;}
-->
</style>
</head>
<center><b><font size="3" face="华文细黑">数据库字段复制工具</font></b></center>
<center><font color=blue>BY_寂寞的刺猬[L.S.T]</font></center>
注:本代码借鉴了“netpatch”的部分代码,特此感谢!<br>
<font color=red>第一步:</font><br>
<form action="" method=post name=form >
请选择欲复制的数据库类型:<br>
<input type="radio" name="mdbsql" value="sql" checked>SQL数据库
<input type="radio" name="mdbsql" value="mdb">MDB数据库<br>
欲复制的字段数:<input type=text name=zhi>
<input type=submit name="button" value="设 置">
</form>
<%
zhi=request.form("zhi")
if zhi>0 then
mdbsql=request.form("mdbsql")
response.write "<font color=red>第二步:</font>"
response.write "<form action='' method=post name=form1>"
response.write "创建的MDB数据库名称:<input type=text name=mdbname>(请带mdb扩展名)<br>"
if mdbsql="sql" then
response.write "SQL数据库用户名称:<input type=text name=sqlusername><br>"
response.write "SQL数据库连接密码:<input type=text name=sqlpwd><br>"
response.write "SQL数据库名称:<input type=text name=sqldataname><br>"
response.write "SQL数据库中表的名称:<input type=text name=sqltable><br>"
response.write "SQL数据库地址:<input type=text name=sqldatasource value='(local)'>(默认)<br>"
elseif mdbsql="mdb" then
response.write "ACCESS数据库名称:<input type=text name=sqldataname>(请带文件扩展名)<br>"
response.write "ACCESS数据库中表的名称:<input type=text name=sqltable><br>"
end if
response.write "<input type=hidden name=mdbsql value=" & mdbsql &">"
response.write "<input type=hidden name='zhi' value=" & zhi &">"
for i=1 to zhi
response.write "欲复制的字段名称:<input type=text name=sqlrow("& i &")>"
response.write "字段类型:<select name=sqltype("& i & ")>"
response.write "<option select value=varchar>文本</option><option select value=memo>备注</option><option select value=integer>数字</option><option select value=datetime>日期/时间</option><option select value=image>OLE对象</option>"
response.write "</select><br>"
next
response.write "<br><center><input type=submit name='button' value='复 制'></center>"
response.write "</form>"
end if
%>
<%
mdbname=request.form("mdbname")
if len(mdbname)>0 then
response.write "<font color=red>第三步:</font><br>"
zhi=request.form("zhi")
sqltable=request.form("sqltable")
sqlusername=request.form("sqlusername")
sqlpwd=request.form("sqlpwd")
sqldataname=request.form("sqldataname")
sqldatasource=request.form("sqldatasource")
mdbsql=request.form("mdbsql")
mdbcreate=""
mdbinsert=""
sqlselect=""
dim srow(),stype()
redim srow(zhi),stype(zhi)
'on error resume next
for i=1 to cint(zhi)
srow(i) =request.form("sqlrow(" & i &")")
stype(i)=request.form("sqltype(" & i &")")
mdbcreate=mdbcreate & "[" & srow(i) & "] " & stype(i) &","
mdbinsert=mdbinsert & srow(i) & "|"
sqlselect=sqlselect & srow(i) & ","
next
mdbcreate=left(mdbcreate,len(mdbcreate)-1)
mdbinsert=left(mdbinsert,len(mdbinsert)-1)
sqlselect=left(sqlselect,len(sqlselect)-1)
call crtable(mdbname,sqltable,mdbcreate)
call copysq(mdbname,sqltable,sqlpwd,sqlusername,sqldataname,sqldatasource,mdbinsert,sqlselect,mdbsql)
end if
%>
<%
function crtable(mdbname,sqltable,mdbcreate)
dbfile=server.mappath(mdbname)
set ydb=server.createobject("adox.catalog")
ydb.create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbfile
set ydb=nothing
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & dbfile
sql="CREATE TABLE [" & sqltable &"](" & mdbcreate &")"
conn.execute(sql)
conn.close
set conn=nothing
end function
function copysq(mdbname,sqltable,sqlpwd,sqlusername,sqldataname,sqldatasource,mdbinsert,sqlselect,mdbsql)
mdbarray=split(mdbinsert,"|")
max=ubound(mdbarray)
dbfile=server.MapPath(mdbname)
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & dbfile
Set rs = CreateObject("ADODB.RecordSet") 'mdb数据库
rs.Open "["& sqltable &"]", conn, 1, 3
if mdbsql="sql" then
set connstr=server.createobject("adodb.connection") 'sql数据库
connstr.open "Provider=SQLOLEDB.1;Password="&sqlpwd&";User ID="&sqlusername&";Database="&sqldataname&";Data Source ="&sqldatasource
elseif mdbsql="mdb" then
filepath1=server.mappath(sqldataname)
set connstr=server.createobject("adodb.connection") 'mdb数据库
connstr.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filepath1
end if
sql1="select "& sqlselect &" from ["& sqltable &"]"
set showbbs=connstr.execute(sql1)
do while not showbbs.eof
rs.addnew
for i=0 to max
rs(mdbarray(i))=showbbs(mdbarray(i))
next
rs.update
showbbs.movenext
loop
showbbs.close
set showbbs=nothing
if err.number=0 then
Response.Write dbfile & " 数据复制成功, "
response.write "<a href="& mdbname &">下载</a>"
else
Response.Write "失败,原因: " & err.description
Response.end
end if
end function
'BY 寂寞的刺猬 2006-08-13
'5200
%>
发表评论 - 不要忘了输入验证码哦!