SQL Parameters

J

Jim Heavey

I am writing a "generic" routine which will return to the "calling"
procedure a list of all of the parameters and the parameter types. The
intent is the calling program will read the "Parm names and Types" and
build a HashTable of the values which will then be passed back to
actually build those parameters.

I do not what to return a "sqlDBType", but I would rather return some
generic type which can be handled by the calling program in the event
that I would change from SQL Server to something else.

I am trying to map the SQLDBTypes to a "universal" or a System.? (e.g
Byte, String, ect.)

Below is my Guesses as to how things will mapp out. I will ultimately
create the parm with the appropriate SQLDBType and will do the
appropriate conversions as necessary.

Am I assigning the right types? Is there a better way to do this?

BigInt Int ???
Binary Byte() ??
Bit Char ??
Char String
DateTime DateAndTime
DecimalFloat Float
Image Byte() ??
Int Integer
Money Double
NChar String
NText String
NVarChar String
Real Double ????
SmallDateTime DateAndTime
SmallInt int16
SmallMoney double
Text string
Timestamp DateAndTime ???
TinyInt int16
UniqueIdentifier ????
VarBinary Byte() ??
VarChar string
Variant object ????
 
D

David Browne

Jim Heavey said:
I am writing a "generic" routine which will return to the "calling"
procedure a list of all of the parameters and the parameter types. The
intent is the calling program will read the "Parm names and Types" and
build a HashTable of the values which will then be passed back to
actually build those parameters.

I do not what to return a "sqlDBType", but I would rather return some
generic type which can be handled by the calling program in the event
that I would change from SQL Server to something else.

I am trying to map the SQLDBTypes to a "universal" or a System.? (e.g
Byte, String, ect.)

Below is my Guesses as to how things will mapp out. I will ultimately
create the parm with the appropriate SQLDBType and will do the
appropriate conversions as necessary.

Use System.Data.DbType. That's what it's there for.

Every provider has a parameter class which implements IDbParameter.DbType.
You can get and set the parameter type using the DbType or the
provider-specific type (eg SqlDBType).

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top