How to prevent wrong data type when use the select statement?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All

I have questions about DataTable Select function. I would like to know how to prevent the used of wrong purpose data type. For example If I have 2 columns that both data type are String. And then I use the select function to select data needed but I forgot the single quote on query statement. The result of this situation is no DataRow return

Does the DataTable alert a warning for me or you have anyway to check it

regards
KPH
 
You can do the following:

select * from table where field = '" &Replace(yourParameterValue, "'", "''")
&"'"

Or alternatively, you can make use of the SqlParameter object. it will
replace all your single quotes.




KPH said:
Hi All,

I have questions about DataTable Select function. I would like to know how
to prevent the used of wrong purpose data type. For example If I have 2
columns that both data type are String. And then I use the select function
to select data needed but I forgot the single quote on query statement. The
result of this situation is no DataRow return.
 
Back
Top