Reputation: 4807
I am having issues writing this string to my SQL 200 database table:
Conversion from string "" to type 'Integer' is not valid.
How can I ensure that my vb.net app writes the above string exactly as it appears, to the field in the table ?
Upvotes: 0
Views: 3110
Reputation: 27220
I believe the only rules for escaping characters are:
_
and %
) with a backslashSo you should easily be able to insert any string you like by first doing 3 search and replaces on your string - replacing '
with ''
, replacing _
with \_
, and replacing %
with \%
Upvotes: 3
Reputation: 7604
I'd recommend using SqlCommand and SqlParameters, rather than raw SQL strings - for a variety of reasons. To escape characters in SQL, by default, I believe you simply need to double them up (eg. ' becomes '').
Upvotes: 4