日期:2014-05-16  浏览次数:20937 次

ACCESS连接,转换成SQL
由于必须使用SQL,但网上的例子一般用的都是ACCESS的,所以请高手帮忙转换下。希望写详细一点。在此,先向各位老师表示感谢。

<%
set adCn=Server.CreateObject("Adodb.Connection")
adCn.open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & server.MapPath("tree.mdb")
parentid=Request.QueryString("id")
set adRs=adCn.execute("select * ,(select count(*) from tree where parentid=subTree.id) as childNum from tree subTree where parentid=" & parentid)
Response.Write("<script>")
Response.Write("var tree=self.parent.tree;")
''加载第一级节点时,应设id为-1
if parentid="-1" then
Response.Write("var toNode=tree.root;")
else
''节点的键值已依次设成n1,n2,n3........
Response.Write("var toNode=tree.nodes['n" & parentid & "'];")
end if
while not adRs.EOF
'''如果icon字段不为空,图标取数据库的值,否则根据是否有子节点取"folder"或"file"。相应地imagelist应提供这两个键值的图标
if(adRs("icon")<>"") then
icon=adRs("icon")
elseif(adRs("childNum")=0) then
icon="file"
else
icon="folder"
end if
''输出添加节点的代码,第三个参数是设键值的
Response.Write "var nNode=tree.add(toNode,'last','" & adRs("text") & "','" & "n" & adRs("id") & "','" & icon & "','" & adRs("exeCategory") & "','" & adRs("exeArgv") & "');"
Response.Write "if(nNode.parent.first.label.innerText=='loading...')nNode.parent.first.remove();"
if(adRs("childNum")<>0) then
Response.Write "nNode.add('loading...');nNode.expand(false);"
end if
adRs.MoveNext
wend 
Response.Write("</script>")
%>



以上是连接access的源码.


我的服务器上,有一个文件夹,里面,已经有一个文件:<!--#include file="Connections/TianShen.asp" -->

此文件内容如下: (通过此文件,可以正常访问到SQL)

<%
' FileName="Connection_odbc_conn_dsn.htm"
' Type="ADO" 
' DesigntimeType="ADO"
' HTTP="true"
' Catalog=""
' Schema=""
Dim MM_TianShen_STRING
MM_TianShen_STRING = "dsn=TianShen;uid=sa;"
%>



由于是初学,请各老师,不要笑话我水平低.

再次,向各位老师,表示谢意.



------解决方案--------------------
新手路过