ASP做查询分析器(Query Analyzer)(II)
sqlultimate.asp--Part B' ++++++++++++++ FK Sub +++++++++++++++++
SUB FK(xdbname, xuserid, xpassword )
Dim strConn,conntemp,rsSchema,PKT,PKC,FKT,FKC
Const adSchemaForeignKeys = 27
strConn = "Provider=SQLOLEDB.1;Data Source="&strServer&";" & _
"Initial Catalog=" & xdbname & _
";UID=" & xuserid & ";PWD=" & xpassword & ";"
set conntemp = server.createobject("adodb.connection")
response.write("<p align=center><table width=""75%"">" & vbCrLf)
response.write("<tr bgcolor=black align=center><td colspan=2><font color=white><b>Primary Key</b></font></td><td colspan=2><font color=white><b>Foreign Key</b></font></td></tr>" & vbCrLf)
response.write("<tr bgcolor=white align=center><td><b>PK Table</b></td><td><b>PK Field</b></td><td><b>FK Table</b></td><td><b>FK Field</b></td></tr>" & vbCrLf)
conntemp.open strConn
set rsSchema = conntemp.OpenSchema(adSchemaForeignKeys)
DO UNTIL rsSchema.eof
PKT = rsSchema.fields("PK_TABLE_NAME")
PKC = rsSchema.fields("PK_COLUMN_NAME")
FKT = rsSchema.fields("FK_TABLE_NAME")
补充:asp教程,高级应用