Reapz Posted February 6, 2004 Posted February 6, 2004 I'm writing an app' that stores info collected from logfiles into a local Access database. When the information has been collected the user can then upload it to a MySQL database on the web. When I add strings to a MySQL DB in PHP I use addslashes() to escape all the reserved characters. I was just wondering if there is an equivalent command in VB.NET. If not I suppose the best way would be to use a regex to escape reserved characters in which case could someone point me to a complete list of them so I an write a fully comprehensive regex. Cheers. Quote I'm getting the hang of this now... No really I am!
Reapz Posted February 10, 2004 Author Posted February 10, 2004 Ok, I'm assuming that means 'No', there isn't an equivalent. So I have manually escaped all the reserved characters by adding backslashes infront of them and now the information is stored correctly in the local database. However, it doesn't work properly. When I run the code that uploads the local DB to the MySQL DB the backslashed characters are left out completely. Any ideas? Quote I'm getting the hang of this now... No really I am!
*Experts* Nerseus Posted February 10, 2004 *Experts* Posted February 10, 2004 I would not store the strings with backslashes - seems more logical to store the data as-is and only add the backslashes as needed, when converting data coming out (a stored procedure, in the query, or through code). For that, I'd use a simple function that escapes everything that's not a letter or digit, just to be safe. If this is on a .NET webserver you can use the Server.HtmlEncode function. If not, I think you can still use the static function - just make a reference to System.Web. -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
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.