This is a multi-part message in MIME format.
------=_NextPart_000_0008_01C3C629.AD311660
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
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 =3D/
--=20
ANDREAS H=C5KANSSON
STUDENT OF SOFTWARE ENGINEERING
andreas (at) selfinflicted.org
------=_NextPart_000_0008_01C3C629.AD311660
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.3790.59" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I have a set of variables (varies in =
type) which I=20
will need to take</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>and make "SQL-safe", that is, if the =
variable is a=20
string i need it</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>to be converted to 'string' and if it's =
a bool then=20
it should be</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>coverted to 0 or 1 etc =
etc..</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>The reason for this is that I need to =
build a query=20
dynamicly and</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>need the conditions (after the where =
clause) to be=20
right formatted.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I thought I might be able to use the =
types in=20
System.Data.SqlTypes</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>but it seems they are unable to return =
"SQL-safe"=20
formatted values</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>(what a shame actually).</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I would reeaaaaaaaally like not to have =
a huge=20
switch (c#) statement</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>which checks for the type and makes the =
correct=20
formatting. So does</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>anyone know of any solution I could =
use? I've=20
looked and looked in</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>the System.Data namespaces without any =
luck.. I've=20
even tried to</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>use the SqlParameter class since when =
using with=20
for instance a</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>SqlCommand, they help give the right =
format,=20
without any luck =3D/</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><BR>-- <BR>ANDREAS =
H=C5KANSSON<BR>STUDENT OF SOFTWARE=20
ENGINEERING<BR>andreas (at) selfinflicted.org</FONT></DIV></BODY></HTML>
------=_NextPart_000_0008_01C3C629.AD311660--