Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determining Data Type

Status
Not open for further replies.

K3V

Programmer
Mar 17, 2005
9
US
I'm developing with VB 6 & Sql Server 2k. I have a

SELECT * from...

statement which returns values of various datatypes, as well as some <NULL> values. When populating text fields from the recordset object, I get "Invalid Use of Null" errors when such is the case.

To correct this, I thought I'd use an "isnull(,) function, but don't no how to deal with the second parameter in this function, when I don't know what column or data type is currently being evaluated...

eg:
select isnull(*,some value) from table

Is there either a typeof() or some similar function which can be included in a case statement to process based on the type returned? How would that be done?

If that can't be done, or if there is a better way to deal with this, please share any ideas.

Thank you for any and all replys!
K3V
 
Invalid Use of Null" is VB error. Why changing SQL code to fix client-side issue?

ADODB.Field object has Type property. Use it to determine column data type.

------
heisenbug: A bug that disappears or alters its behavior when one attempts to probe or isolate it
schroedinbug: A bug that doesn't appear until someone reads source code and realizes it never should have worked, at which point the program promptly stops working for everybody until fixed.
 
Very good! Thank you for your quick response! I'll give that a whirl.
 
using this method, iterating through the columns to check for type, is the "Field" property zero-based, (x = 0 to x - 1) or one-based? x = 1 to (max)

K3V
 
Found my answer... zero-based.

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top