?
=?iso-8859-1?Q?Andreas_H=E5kansson?=
I have a set of variables (varies in type) which I will need to take
and make "SQL-safe", that is, if the variable is a string i need it
to be converted to 'string' and if it's a bool then it should be
coverted to 0 or 1 etc etc..
The reason for this is that I need to build a query dynamicly and
need the conditions (after the where clause) to be right formatted.
I thought I might be able to use the types in System.Data.SqlTypes
but it seems they are unable to return "SQL-safe" formatted values
(what a shame actually).
I would reeaaaaaaaally like not to have a huge switch (c#) statement
which checks for the type and makes the correct formatting. So does
anyone know of any solution I could use? I've looked and looked in
the System.Data namespaces without any luck.. I've even tried to
use the SqlParameter class since when using with for instance a
SqlCommand, they help give the right format, without any luck =/
and make "SQL-safe", that is, if the variable is a string i need it
to be converted to 'string' and if it's a bool then it should be
coverted to 0 or 1 etc etc..
The reason for this is that I need to build a query dynamicly and
need the conditions (after the where clause) to be right formatted.
I thought I might be able to use the types in System.Data.SqlTypes
but it seems they are unable to return "SQL-safe" formatted values
(what a shame actually).
I would reeaaaaaaaally like not to have a huge switch (c#) statement
which checks for the type and makes the correct formatting. So does
anyone know of any solution I could use? I've looked and looked in
the System.Data namespaces without any luck.. I've even tried to
use the SqlParameter class since when using with for instance a
SqlCommand, they help give the right format, without any luck =/