yaniv Posted June 14, 2003 Posted June 14, 2003 Do you have an idea how to solve the inverted commas (e.g. ") problem, when the user type it into the textbox and you send it to the database (you get a problem with your string). What's the best way that worked for you? Quote
*Experts* mutant Posted June 14, 2003 *Experts* Posted June 14, 2003 I never had a problem with that but you could go through the whole string and replace " with '. Quote
wyrd Posted June 14, 2003 Posted June 14, 2003 Mutant: I don't think SQL Server has a problem with single " but does have a problem with single '. He's probably using Access? Anyway to the problem.. You could do a String.Replace("\"", "\"\"") or as mutant suggested, replace it with ' like so; String.Replace("\"", "'"). For SQL Server I usually just do a String.Replace("'", "''") (replace ' with two ''). There's also a SQL Server function which will take care of all of this for you, but unfortunately I can't remember what it is off of the top of my head. Quote Gamer extraordinaire. Programmer wannabe.
yaniv Posted June 15, 2003 Author Posted June 15, 2003 well, the the problem is indeed the '. the String.Replace is just great (Although you have to add it to any text you send and get back from the database.) thanks yaniv Quote
wyrd Posted June 15, 2003 Posted June 15, 2003 You should only have to do a String.Replace() on data going into the database. Once it's in there it should be stored with single ' and retrieved with single ' as well. Quote Gamer extraordinaire. Programmer wannabe.
yaniv Posted June 16, 2003 Author Posted June 16, 2003 But. if i want the user to the dounle one - ", and not the single, i should do it twice - to replace it in the way to the database in some other, unused, char, and then to replace it again in the way to the app. the "problem" is that both are very usefull in hebrew so i have to make them usufull for the clinet. Quote
wyrd Posted June 16, 2003 Posted June 16, 2003 :confused: Quote Gamer extraordinaire. Programmer wannabe.
yaniv Posted June 16, 2003 Author Posted June 16, 2003 Some thing happened to my post, what I meant was: The string.replace is good if you want to change permanently one char to another, but if you want to keep the char (in the user point of view) then you have to replace it twice, one time when you send it to the database and one when you show it to the user again. Don't you? Quote
wyrd Posted June 16, 2003 Posted June 16, 2003 I don't believe so. Like most other string alteration methods, it should return a string with the changes made and leave the current string in tact. I remember having a problem with this when trying to use String.Trim(), I had to do str = str.Trim(). Little odd IMO but it seems to be the way most methods work. Quote Gamer extraordinaire. Programmer wannabe.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.