【www.gdgbn.com--系统相关】

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("

" & vbCrLf)
        response.write("Primary KeyForeign Key" & vbCrLf)
        response.write("PK TablePK FieldFK TableFK Field" & 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")

本文来源:http://www.gdgbn.com/aspjiaocheng/7428/