• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

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

发布: 2007-6-30 18:56 | 作者: admin | 来源: | 查看: 16次 | 进入软件测试论坛讨论

领测软件测试网 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
      For Each tbl In cat.Tables
      
        If tbl.Type = "TABLE" Then
            For Each fld In tbl.columns
                If selectIdentity(connectstring,tbl.name,fld.name) = 1 Then
                   strCookieIdentity = strCookieIdentity & tbl.name & fld.name
                End If
            Next  
        End If
        
      Next

    set cat = nothing
    set tbl = nothing
    cnn.Close
    set cnn = nothing
    response.cookies(xdbname & "strCookieIdentity") = strCookieIdentity & xdbname
end sub    


Function getType(strFieldTypeNumber)

Dim strFieldType

Select Case strFieldTypeNumber

        Case 0x2000
               strFieldType = "adArray"
        Case 20
            strFieldType = "adBigInt"        
        Case 128
            strFieldType = "adBinary"
        Case 11
            strFieldType = "adBoolean"
        Case 8
            strFieldType = "adBSTR"
        Case 136
            strFieldType = "adChapter"
        Case 129
            strFieldType = "adChar"
        Case 6
            strFieldType = "adCurrency"
        Case 7
            strFieldType = "adDate"
        Case 133
            strFieldType = "adDBDate"
        Case 137
            strFieldType =     "adDBFileTime"
        Case 134
            strFieldType =     "adDBTime"
        Case 135
            strFieldType = "adDBTimeStamp"
        Case 14
            strFieldType = "adDecimal"
        Case 5
            strFieldType = "adDouble"
        Case 0
            strFieldType = "adEmpty"
        Case 10    
            strFieldType = "adError"
        Case 64
            strFieldType =     "adFileTime"
        Case 72
            strFieldType = "adGUID"
        Case 9
            strFieldType = "adIDispatch"
        Case 3
            strFieldType = "adInteger"
        Case 13
            strFieldType = "adIUnknown"
        Case 205    
            strFieldType = "adLongVarBinary"
        Case 201
            strFieldType = "adLongVarChar"
        Case 203
            strFieldType = "adLongVarWChar"
        Case 131
            strFieldType = "adNumeric"
        Case 138
            strFieldType = "adPropVariant"
        Case 4
            strFieldType = "adSingle"
        Case 2
            strFieldType = "adSmallInt"
        Case 16
            strFieldType = "adTinyInt"
        Case 21
            strFieldType = "adUnsignedBigInt"
        Case 19
            strFieldType = "adUnsignedInt"
        Case 18
            strFieldType =    "adUnsignedSmallInt"
        Case 17
            strFieldType =    "adUnsignedTinyInt"
        Case 132
            strFieldType =    "adUserDefined"
        Case 204
            strFieldType =    "adVarBinary"
        Case 200
            strFieldType =    "adVarChar"
        Case 12
            strFieldType =    "adVariant"
        Case 139
            strFieldType =    "adVarNumeric"
        Case 202
            strFieldType =    "adVarWChar"
        Case 130    
            strFieldType =    "adWChar"
        Case Else
              strFieldType = "Unknown Data Type"
            
    End Select

   getType = strFieldType
End Function
%>

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网