Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: openschema- DATA_TYPE as string


Message #1 by speedguru@m... on Fri, 27 Jul 2001 15:37:39
hi,



i'm using connection.openschema to show all the tables in a database.

rs("DATA_TYPE") returns the numeric equivalent of the column data-type. 

where (or how)can i get the string equivalents. 



if anybody has it already can u pls pass it on so that i can hard-code it 

using select-case....





cheerio,

:-)rk





Message #2 by Steve Carter <Steve.Carter@t...> on Fri, 27 Jul 2001 16:08:32 +0100
It's in the M$DN pages but I've lost it since they reorg'd.



Here's one bit of code I hacked to do it.



You need to #include the adovbs.inc file for this to work.



Even then it might be ropey (I don't have anywhere to test it

right now)



    <TABLE width=100 cellspacing=0 cellpadding=2><TR bgcolor="#ffeeee">

      <TH>Name</TH>

      <TH>Type</TH>

      <TH>Precision</TH>

      <TH>NumericScale</TH>

      <TH>DefinedSize</TH>

      <TH>Attributes</TH>

      <TH>Properties</TH>

      </TR><%

      for each f in ors2.Fields%>

      <TR bgcolor="#eeffee">

        <TD><%=f.name%></TD>

        <TD><%

        select case f.type

        case adarry %>

          array

        <%

        case adBigInt %>

          adBigInt

        <%

        case adBinary %>

          adBinary

        <%

        case adBoolean %>

          adBoolean

        <%

        case adBSTR %>

          adBSTR

        <%

        case adChapter %>

          adChapter

        <%

        case adChar %>

          adChar

        <%

        case adCurrency %>

          adCurrency

        <%

        case adDate %>

          adDate

        <%

        case adDBDate %>

          adDBDate

        <%

        case adDBTime %>

          adDBTime

        <%

        case adDBTimeStamp %>

          adDBTimeStamp

        <%

        case adDecimal %>

          adDecimal

        <%

        case adDouble %>

          adDouble

        <%

        case adEmpty %>

          adEmpty

        <%

        case adError %>

          adError

        <%

        case adFileTime %>

          adFileTime

        <%

        case adGUID %>

          adGUID

        <%

        case adIDispatch %>

          adIDispatch

        <%

        case adInteger %>

          adInteger

        <%

        case adIUnknown %>

          adIUnknown

        <%

        case adLongVarBinary %>

          adLongVarBinary

        <%

        case adLongVarChar %>

          adLongVarChar

        <%

        case adLongVarWChar %>

          adLongVarWChar

        <%

        case adNumeric %>

          adNumeric

        <%

        case adPropVariant %>

          adPropVariant

        <%

        case adSingle %>

          adSingle

        <%

        case adSmallInt %>

          adSmallInt

        <%

        case adTinyInt %>

          adTinyInt

        <%

        case adUnsignedBigInt %>

          adUnsignedBigInt

        <%

        case adUnsignedInt %>

          adUnsignedInt

        <%

        case adUnsignedSmallInt %>

          adUnsignedSmallInt

        <%

        case adUnsignedTinyInt %>

          adUnsignedTinyInt

        <%

        case adUserDefined %>

          adUserDefined

        <%

        case adVarBinary %>

          adVarBinary

        <%

        case adVarChar %>

          adVarChar

        <%

        case adVariant %>

          adVariant

        <%

        case adVarNumeric %>

          adVarNumeric

        <%

        case adVarWChar %>

          adVarWChar

        <%

        case adWChar %>

          adWChar

        <%

        case else 

          Response.Write "[" & f.type & "]"        

        end select

        %></TD>

        <TD><%=f.precision%></TD>

        <TD><%=f.NumericScale%></TD>

        <TD><%=f.DefinedSize%></TD>

        <TD><%=f.Attributes%></TD>

        <TD style="text-align: left">

        <TABLE class="little" cellpadding=0 cellspacing=0 border=0><%

        set col = server.CreateObject("Scripting.Dictionary")

        t1 = "<TR class=""littlel""><TD class=""littlel"">"

        t2 = " </TD><TD class=""little"">"

        t3 = "</TD></TR>"



        for each p in f.properties

          select case p.type

          case 202 ' string

            if trim(p.value)<>"" then

              Response.Write t1 & p.name & t2 & p.value & t3

            end if

          case 9 ' interface ptr

            if not (p.value is null) then

              Response.Write t1 & p.name & t2 & " points to a com interface"

& t3

            end if

          case 72 ' interface ptr

          case 3'19 ' numerics

            if typename(p.value)<>"Null" then

              Response.Write t1 & p.name & t2 & p.value & t3

            end if

          case 11 ' boolean

            if p.value then col.Add p.name,p.name

          case 12 ' variant

            if typename(p.value)<>"Null" then

              Response.Write t1 & "Variant " & p.name & t2 & "= (" &

typename(p.value) & "): " & p.value & t3

            end if

          case 19' unsupported 

          case else

            Response.Write t1 & "(" & p.name & t2 & " is of type " & p.type

& ")" & t3

          end select

        next

        if col.Count>0 then

          str = ""

          for each a in col

            str = str & "|" & a

          next

          Response.Write t1 & "Flags" & t2t & mid(str,2) & t3

        end if

        set col=nothing

        %></TABLE></TD><%

      next %>

    </TABLE>





> -----Original Message-----

> From: speedguru@m... [mailto:speedguru@m...]

> Sent: 27 July 2001 16:38

> To: ASP Databases

> Subject: [asp_databases] openschema- DATA_TYPE as string

> 

> 

> hi,

> 

> i'm using connection.openschema to show all the tables in a database.

> rs("DATA_TYPE") returns the numeric equivalent of the column 

> data-type. 

> where (or how)can i get the string equivalents. 

> 

> if anybody has it already can u pls pass it on so that i can 

> hard-code it 

> using select-case....

> 

> 

> cheerio,

> :-)rk


  Return to Index