====================================ljmdb.asp
<
setconndb=server.createobject("ADODB.CONNECTION")
constr="provider=microsoft.jet.oledb.4.0;data
source="&server.mappath("/aspsky.myip.org/entice.mdb")
conndb.openconstr
>
'这是连接access的,把数据库的地址改成你自己的地址就行了
====================================entice.asp
<
ifleft(trim(request("sqllanguage")),6)="select"then
>
<scriptlanguage=javascript>
window.open("entice2.asp?sql=<=request("sqllanguage")>","","height=450,width=600,resizable=yes,
scrollbars=yes,status=no,toolbar=no,menubar=no,location=no")
</script>
<
endif
>
<!--#includefile=ljmdb.asp-->
<
>
<HTML>
<Title>SOL语句执行示例</Title>
<styletype="text/css">
<!--
body{font-size:12px}
table{font-size:12px}
-->
</style>
<BodyBgcolor=#009999>
<
sqllanguage=Request("sqllanguage")
>
<FormName="FormPst"Method="Post"Action="entice.asp">
<divalign="center"><FieldSet><Legend>请输入SQL语句</Legend>指令:
<Inputtype="text"name="sqllanguage"Size=60>
<Inputtype="Submit"Value="送出">
</FieldSet></div>
</form>
<Hr>
SQL语句执行情况:
<
ifsqllanguage<>Emptythen
OnErrorResumeNext
conndb.Execute(sqllanguage)
iferr.number="0"then
message1="执行成功"
response.writemessage1
else
message1=err.description
response.writemessage1
err.clear
endif
endif
>
<
setrstable=conndb.openSchema(20)
rstable.movefirst
>
<tablewidth="95"border="0"cellspacing="1"cellpadding="3"align="center"bgcolor="#000000">
<
dowhilenotrstable.eof
ifrstable("table_type")="TABLE"then
>
<trbgcolor="#006400">
<tdwidth="18"nowrap><fontcolor="#FFFFFF">数据库中的表名</font></td>
<tdwidth="82"nowrap><fontcolor="#FFFFFF">
<
response.writerstable("table_name")
>
</font></td>
</tr>
<trbgcolor="#CCCCCC">
<tdwidth="18"nowrap>该表中的所有字段</td>
<tdwidth="82"nowrap>
<
setrstobj=server.createobject("adodb.recordset")
rstsql="select*from"&rstable("table_name")
rstobj.openrstsql,conndb,1
fori=0torstobj.fields.count-1
response.writerstobj(i).name&"|"
next
rstobj.close
setrstobj=nothing
>
</td>
</tr>
<
endif
rstable.movenext
loop
rstable.close
setrstable=nothing
>
</table>
</Body>
</HTML>
<
conndb.close
setconndb=nothing
>
=====================================entice2.asp
<Title>select查询器====entice</Title>
<styletype="text/css">
<!--
body{font-size:12px}
table{font-size:12px}
-->
</style>
<BodyBgcolor=#009999>
<!--#includefile=ljmdb.asp-->
<
rstsql=request("sql")
response.write"你的查询语句为:"&rstsql&"
下面是您所查询的记录集"
setrstobj=server.createobject("adodb.recordset")
rstobj.openrstsql,conndb,1
response.write",共查到"&rstobj.recordcount&"条记录"
fcount=rstobj.fields.count
response.write"<tablewidth='98'border='0'cellspacing='1'cellpadding='3'align='center'
bgcolor='#000000'><trbgcolor='#006400'>"
fori=0tofcount-1
response.write"<td><fontcolor='ffffff'>"&rstobj(i).name&"</font></td>"
next
response.write"</tr>"
dowhilenotrstobj.eof
response.write"<trbgcolor='#cccccc'>"
fori=0tofcount-1
response.write"<td>"&rstobj(i)&"</td>"
next
response.write"</tr>"
rstobj.movenext
loop
response.write"</table>"
rstobj.close
setrstobj=nothing
conndb.close
setconndb=nothing
>

RSS订阅







