vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| pbd22 wrote: > Could somebody tell me how i handle single quotes in an insert > statement? > Or, for that matter, anythign that would break the insert? > > I have a TEXT column that takes tons of text. > > Thanks. > Peter > What language are you using? -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
| |||
| "pbd22" <dushkin@gmail.com> wrote in message news:515da953-e922-450f-ab12-9d05cc15cd6d@n36g2000hse.googlegroups.com... > > Thanks. > > I am using VB.NET/MySQL 5.0 > If you use parameterised updates then your data would be automatically fixed for you. This is available using MySqlConnector. Otherwise you should replace certain character sequences. Heres the code I used once (C#) which provides the SqlEscapes method to convert your data ... private static Regex _FromToRegex = new Regex(@"([\\\n\r\b\t'""\x1a\x00])",RegexOptions.Compiled); public static string FromToMatchEvaluator(Match match) { switch (match.Value) { case "\\": return "\\\\"; case "\n": return "\\n"; case "\r": return "\\r"; case "\b": return "\\b"; case "\t": return "\\t"; case "\x1a": return "\\Z"; case "\x00": return "\\0"; case "'": return "\\'"; case "\"": return "\\\""; default: return match.Value; } } public static string SqlEscapes(string s) { return _FromToRegex.Replace(s,new MatchEvaluator(FromToMatchEvaluator)); } Tigger |
| ||||
| "pbd22" <dushkin@gmail.com> wrote in message news:031ac615-313e-4129-b7b6-966263221530@59g2000hsb.googlegroups.com... > Thanks a bunch. > > Will these special characters display? > > Peter Not sure what you mean. The encoding is only so you can write sql that stores your data correctly in the database, letting you retreive it as it originally was. Displaying the date is a completely seperate thing. Tigger |