ASP做查询分析器(Query Analyzer)(V)

80酷酷网    80kuku.com

  查询分析DataTypeLib.asp

<%
Function selectIdentity(strConnect,strTable,strColumn)
Dim objConn, objRS, strFieldName, strFieldType, arrData, intRowCounter, intColCounter, strFieldValue
Dim intUBoundRow, intUBoundCol, strSQLID
Set objConn=Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = strConnect
objConn.Open
strSQLID = "SELECT COLUMNPROPERTY( OBJECT_ID('"&strTable&"'),'"&strColumn&"','IsIdentity')"
Set objRS = objConn.Execute(strSQLID)
        If objRS.EOF and objRS.BOF then
            Response.Write("No records matched or table is empty")
            objRS.Close
            Set objRS = Nothing
            objconn.Close
            Set objconn=Nothing
        Else
            ' Now lets grab all the records and close objects
            arrData=objRS.Getrows
            objRS.Close
            Set objRS = Nothing
            objConn.Close
            Set objConn = Nothing
            
            intUBoundRow = UBound(arrData,2)
            intUBoundCol = UBound(arrData,1)
            For intRowCounter = 0 to intUBoundRow
                For intColCounter = 0 to intUBoundCol
                    strFieldValue = arrdata(intcolcounter,introwcounter)
                    If isNull(strFieldValue) then
                        strFieldValue ="<NULL>"
                    Elseif trim(strFieldValue)="" then
                        strFieldValue="<BLANK>"
                    End if
                Next
            Next
        End if
    selectIdentity = strFieldValue
End Function


Sub getIdentity(strServer, xdbname, xuserid, xpassword)

dim cnn, cat, tbl, fld, strCookieIdentity
dim connectstring
  connectstring = _
                "Provider=SQLOLEDB.1;Data Source="&strServer&";" & _
                "Initial Catalog=" & xdbname & _
                ";UID=" & xuserid & ";PWD=" & xpassword & ";"
        
  set cnn = server.createobject("adodb.connection")
  set cat = server.createobject("adox.catalog")
  set tbl = server.createobject("adox.table")
  set fld = server.createobject("adox.column")
  
  cnn.Open connectstring
  
  cat.ActiveConnection = cnn
  

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: