Create correct DB type from String value

  • Thread starter Thread starter Ondrej Sevecek
  • Start date Start date
O

Ondrej Sevecek

Hello,
I have

String paramName = "@param1";
String paramValue = "100";
SqlDBType paramType = SqlDBType.BigInt;
int paramSize = 4;

and want to type the "paramValue" to the appropriate type for
"SqlParameter"

SelectCommand.Parameters.Add(paramName, paramType, paramSize).Value =
????????;


Nice day
Ondra.
 
Hi Ondrej

SqlDBType.BigInt maps to Int64 .net type thus its size should be 8 bytes
(and not 4).

For more details see
SqlDbType Enumeration
..net help topic.
 
The paramSize value is not esential (I have done it wrong, certainly). I
would like to REtype the String to the type defined by paramType
enumeration.

Understand, user supplies paramXXX variables into my dialog box and I must
create appropriate SqlParameter for DataAdapter.

Ondra.
 
Back
Top