Important alert: (current site time 7/15/2013 10:29:59 PM EDT)
 

VB icon

ADODBTypeName

Email
Submitted on: 4/21/2002 8:52:45 PM
By: Lewis E. Moten III  
Level: Beginner
User Rating: By 2 Users
Compatibility: ASP (Active Server Pages)
Views: 13375
author picture
(About the author)
 
     Quickly find out the type of variables returned from your adodb recordset. TypeName() function doesn't do the trick. Databases offer additional data types. This script helps solve type problems without having to lookup the name of the numbers returned.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: ADODBTypeName
' Description:Quickly find out the type of variables returned from your adodb recordset. TypeName() function doesn't do the trick. Databases offer additional data types. This script helps solve type problems without having to lookup the name of the numbers returned.
' By: Lewis E. Moten III
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=7470&lngWId=4'for details.'**************************************

Response.write ADODBTypeName(Rs.Fields("UserID").Type)
Function ADODBTypeName(ByRef plngType)
	Select Case plngType
		Case 0:ADODBTypeName="adEmpty"
		Case 2:ADODBTypeName="adSmallInt"
		Case 3:ADODBTypeName="adInteger"
		Case 4:ADODBTypeName="adSingle"
		Case 5:ADODBTypeName="adDouble"
		Case 6:ADODBTypeName="adCurrency"
		Case 8:ADODBTypeName="adBSTR"
		Case 9:ADODBTypeName="adDispatch"
		Case 10:ADODBTypeName="adError"
		Case 11:ADODBTypeName="adBoolean"
		Case 12:ADODBTypeName="adVariant"
		Case 13:ADODBTypeName="adIUnknown"
		Case 14:ADODBTypeName="adDecimal"
		Case 16:ADODBTypeName="adTinyInt"
		Case 17:ADODBTypeName="adUnsignedTinyInt"
		Case 18:ADODBTypeName="adUnsignedSmallInt"
		Case 19:ADODBTypeName="adUnsignedInt"
		Case 21:ADODBTypeName="adUnsignedBigInt"
		Case 64:ADODBTypeName="adFileTime"
		Case 72:ADODBTypeName="adGUID"
		Case 20:ADODBTypeName="adBigInt"
		Case 128:ADODBTypeName="adBinary"
		Case 129:ADODBTypeName="adChar"
		Case 130:ADODBTypeName="adWChar"
		Case 131:ADODBTypeName="adNumeric"
		Case 132:ADODBTypeName="adUserDefined"
		Case 133:ADODBTypeName="adDBDate"
		Case 134:ADODBTypeName="adDBTime"
		Case 135:ADODBTypeName="adDBTimeStamp"
		Case 136:ADODBTypeName="adChapter"
		Case 137:ADODBTypeName="adDBFileTime"
		Case 138:ADODBTypeName="adPropVariant"
		Case 139:ADODBTypeName="adVarNumeric"
		Case 200:ADODBTypeName="adVarChar"
		Case 201:ADODBTypeName="adLongVarChar"
		Case 202:ADODBTypeName="adVarWChar"
		Case 203:ADODBTypeName="adLongVarWChar"
		Case 204:ADODBTypeName="adVarBinary"
		Case 205:ADODBTypeName="adLongVarBinary"
	End Select
End Function


Other 102 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
5/18/2002 2:27:01 AMneil@efc.be

First, thanks for all your submissions. They are appreciated.
In the ADODBTypeName description you state that TypeName() doesn't do the trick. Could you be a bit more specific as I have been using it quite a lot recently.

Ta

Neil
(If this comment was disrespectful, please report it.)

 
5/21/2002 8:39:05 AMLewis Moten

TypeName has problems because you can't determine between specific types. You can do a test by creating a table with all the different data types. Select all fields from the table and do a typename on each one. You'll see that some are the same when they are not.
(If this comment was disrespectful, please report it.)

 
7/15/2003 5:55:45 AM

useful snippet, thanks!

but with select case statements i always use a case else at the end..it's safer in case you haven't covered all of the possible options.

ie:

Case Else: ADODBTypeName="UNKNOWN"
End Select
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.