Replace(txt,"'","''") in code-behind

i'm creating a file named client.vb using my wordpad. I'm using this as a code-behind sort of thing. The problem is I want to remove the ' from my strings so that i can put them in SQL statements. The Replace doesn't work, is there any other way to this. thanks.
0
iceman2004
8/10/2004 7:57:30 PM
asp.net.getting-started 91979 articles. 4 followers. Follow

5 Replies
1243 Views

Similar Articles

[PageSpeed] 10
Get it on Google Play
Get it on Apple App Store

Can you show me the code sample you have for the string.Replace() method? That should work for you.
0
david5517
8/10/2004 8:07:37 PM
You should instead use Sql Parameters to compile and send your query to the db.  One of the many benefits of doing so is that you don't need to worry about the single quotes.
-- daver
0
daver
8/10/2004 8:25:33 PM
True. However, I'd like to know why you are having the experience that the Replace function is not working. Let's see some code.
0
david5517
8/10/2004 8:31:32 PM
well basically what happen is this, i ported from my vbscript asp code to asp.net so my code would look like this. Using OLEDB connections.


Sub MySub()
..
..
..
Dim strTemp
strTemp = Replace(txt_description.text,"'","''")
sql = Insert into tbl(desc) values ('" & strTemp & "')
..
..
..
End Sub

I think i should use the string.replace method then :) thanks or look into that SQL parameters.
0
iceman2004
8/11/2004 3:08:05 AM

What does the resulting SQL string look like?

Steven Bey

Recursion: see Recursion
0
stevenbey
8/11/2004 8:29:01 AM
Reply: