Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

I'm getting the hang of this now... No really I am!
Posted

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?

I'm getting the hang of this now... No really I am!
  • *Experts*
Posted

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

"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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...