DB type from user string input

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

Ondrej Sevecek

Hello,
I have dialog box, where user should insert the following:
SQL parameter name
SQL parameter type
SQL parameter length (optional)
SQL parameter value!!!!

these values are represented as follows:

String paramName = ...;
String paramValue = ...;
DBType paramType = ...;
int paramSize = ...;

I need to create "SqlParameter" object from user supplied input values so
that the "paramValue" is appropriatelly converted?? (must it be converted?)
to the type specified by
"paramType" user input.

I want then call some stored procedure with the "SqlParameter" constructed
from user input.

Is there a way?

Ondra.
 
Ondra,

Take a look at all the methods of System.Enum. You'll find the static
methods you need to get a list of Enumeration member names (GetNames) to
build a drop-down from, as well as a way to convert those back into
enumeration values (Parse), as well as helpful code samples.

--Bob
 
Ondra,

I'm sorry, I completely misread your question, and it's not because you were
anything but clear. Been a long day.

I don't know offhand how to do what you're attempting without a brute-force
case statement to call the appropriate static conversion method for each
type name, but there is probably some way to do it via reflection.

--Bob
 
Back
Top