フロッグカエルの推奨事項:ASPを実装するonlytiancaiブログからツリー構造の選択
キーワードカエルの推奨事項:ASPは木の構造を実装します
ソース
<! -
------------[test]Table generation script-------------------------------------------------------------------------------------------------------------
ifexists(select*fromdbo.sysobjectswhereid = object_id(n '[dbo]。[test]')andobjectproperty(id、n'isusertable ')= 1)
droptable [dbo]。[テスト]
行く
createTable [dbo]。[テスト](
[id] [int] ID(1,1)notnull、
[str_note] [nvarchar](50)collatechinese_prc_ci_asnull、
[father_id] [int] null
)[プライマリ]
行く
- >
<! -
***************************テストデータ****************
[id] [str_note] [father_id]
[1] [コンピューターブック] [0]
[2] [ソフトウェア開発] [1]
[3] [ハードウェア修理] [1]
[4] [ASP] [2]
[5] [PHP] [2]
[6] [JSP] [2]
[7] [HTML] [2]
[8] [修理を表示] [3]
[9] [マザーボードの修理] [3]
[10] [グラフィックカードの修理] [3]
[11] [VBS Basics] [4]
[12] [HTML Basics] [4]
[13] [Ado Basics] [4]
[14] [ステートメントを行う] [11]
[15] [声明のため] [11]
[16] [ステートメントを選択] [11]
*************************************************
- >
<%
Dimstrconn、Conn、RS、SQL
strconn = "driver = {sqlserver}; server = localhost; database = wawavote; uid = sa; pwd = sa;"
ディミ
i = 0
functionshowtree(parentid)
i = i+1
薄暗い
setrs = server.createObject( "adodb.recordset")
sql = "selectid、str_note、father_id、(selectstr_notefromtesttt2wheret2.id = t1.father_id)asparentnamefromtestttt1wheret1.father_id ="&cint(parentid)
rs.opensql、strconn、1,1
dowhileenotrs.eof
forj = 1toi
respons.write( "---")
次
respons.write(rs(1)& "["&rs(3)& "] <br>")
showtreers(0)
i = i-1
rs.movenext
ループ
rs.close:setrs = Nothing
エンド機能
サブショーテーブル(表)
薄暗い
setrs = server.createObject( "adodb.recordset")
sql = "select*from"&trim(table)
rs.opensql、strconn、1,1
fori = 0tors.fields.count-1
respons.write( "["&rs.fields(i).name& "]")
次
respons.write( "<br>")
dowhileenotrs.eof
fori = 0tors.fields.count-1
Response.write( "["&rs.fields(i).value& "]")
次
respons.write( "<br>")
rs.movenext
ループ
rs.close:setrs = Nothing