日期:2013-06-08  浏览次数:21146 次

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")
            FKC = rsSchema.fields("FK_COLUMN_NAME")
            If PKT <> "" Then
               response.write("<tr align=right><td bgcolor=#c6e9f4>" &PKT & "</td><td> " &  PKC & "</td><td bgcolor=#c6e9f4> " & FKT& "</td><td> " & FKC & "</td></tr>" & vbCrLf)
            End If
         rsSchema.MoveNext
         LOOP
       response.write("</table></p>" & vbCrLf)
   rsSchema.Close
   set rsSchema=nothing
   conntemp.close
   set conntemp=nothing
END SUB

'   ++++++++++++++   tableDropDown Sub  +++++++++++++++++

Sub tableDropDown(xdbname, xuserid, xpassword )

dim cnn, cat, tbl

dim connectstring
On Error Resume Next
  connectstring = _
                "Provider=SQLOLEDB.1;Data Source="&strServer&";" & _
                "Initial Catalog=" & xdbname & _
                ";UID=" & xuserid & ";PWD=" &