Hi All,
I am trying to store a link to a document in a mysql database using VB.NET. I open a file browser for the user to select the file, and if I output the returned filename to a messagebox it looks fine, but when I write that filename string to the SQL database it removes all of the backslash characters.

The messagebox output shows my filename string to be: C:\Temp\EULA.TXT
The field in the SQL database is: C:TempEULA.TXT

Is there a special data type I need to use (either in VB.net or in mysql) to store the filepathname? How can I stop it stripping out the '\' characters. I am currently storing it as a String in VB and as varchar(255) in mysql. Please note I am not trying to upload a file into the database, just store the filename and path.


Edited 3 Years Ago by toomutch

Are you using a parameterized query, are you concatenating the value into the insert statement, do you use datatables ?
Please share the code that inserts this into your db.

Hi All,
Adam K got it spot on with the first reply! Two team points to you. I converted the code to use parameters rather than just list the values of the field and this cured the problem. I am new to SQL (although have been programming in other languages for 30+ years) and only found out about the benefits of passing parameters to an insert or update statement well into my current project.
@radhakrishna.p - I have a database containing all of our current engineering jobs. I wanted users to be able to 'attach' or link a document to each job (e.g. a scan of the jobsheet, or a PDF of the invoice for example). Any reason? Have I missed a trick somewhere?

Thanks to all who replied.

This question has already been answered. Start a new discussion instead.