利用openschema可以获得所有表的主键,当然这只是它的很多功能中的一个。
connstr = "Provider=MSDAORA.1;User ID=liujincai;password=ljc1001;Data Source=hp1"
set mm=server.CreateObject("adodb.connection")
mm.Open connstr
Const adSchemaPrimaryKeys = 28
set rs=mm.OpenSchema(adSchemaPrimaryKeys)
Response.Write "<table>"
Response.Write "<TR>"
for i=0 to rs.fields.count-1
Response.Write "<td>" & rs(i).name & "</td>"
next
Response.Write "</tr> "
do while not rs.eof
Response.Write "<tr>"
for i=0 to rs.fields.count-1
Response.Write "<td>" & rs(i) & "</td>"
next
Response.Write "</tr> "
rs.movenext
loop
Response.write “</table>“
'下面的语句获得表'TB_HOUSE_MAIN'的主键所在的字段
rs.Filter="TABLE_NAME='TB_HOUSE_MAIN'"
if not(rs.eof and rs.bof) then Response.Write rs("COLUMN_NAME")