日期:2014-05-17 浏览次数:21147 次
<% sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\AA.mdb;" Set conn = CreateObject("ADODB.Connection") conn.Provider = "MSDataShape" conn.ConnectionString = "Data " & sConn conn.Open sql = "SHAPE{SELECT DISTINCT cid FROM tb} " & _ "APPEND({" &_ "SELECT cid, name, hangye FROM tb " &_ "} AS tbl " & _ "RELATE cid TO cid)" s = "" Set rs = CreateObject("ADODB.Recordset") rs.CursorLocation = 3 rs.Open sql, conn, 1, 1 Do While Not rs.EOF s = s & rs("cid").Value Set rs1 = rs("tbl").Value n = "/" h = "/" Do While Not rs1.EOF If InStr(n, "/" & rs1("name").Value &"/") = 0 Then n = n & rs1("name").Value & "/" End If If InStr(h, "/" & rs1("hangye").Value &"/") = 0 Then h = h & rs1("hangye").Value & "/" End If rs1.MoveNext Loop rs1.Close Set rs1 = Nothing If n<>"" Then n = Left(n, Len(n)-1) n = Right(n, Len(n)-1) End If If h<>"" Then h = Left(h, Len(h)-1) h = Right(h, Len(h)-1) End If s = s & " " & n & " " & h & "<br>" & vbCrLf rs.MoveNext Loop rs.Close Set rs = Nothing conn.Close Set conn = Nothing Response.Write s %>