-1

I have a strange problem. I have a ASP.NET app which is storing files. I have a table (SQL 2008 R2) where I store the file information on files which are uploaded by my users.

Once in awhile, when I store a filename from an international user with a special character, the name is converted when stored in the database table: Example original filename: Łinename.mov Stored filename: Linename.mov

When I retrieve the filename to build my path/file string, the names don't match and my file is not found.

The table stores the filename as nvarchar, and I thought that would allow unicode characters.

Any ideas? I would prefer to store the original filename, and not rename the file on the server.

EDIT: I think the issue is that the character in question is not in the UTF-8 character set. I solved this by keeping my life simple: I support UTF-8, and if the file is converted when stored as UTF-8, that is my server filename.

1
  • What's the table schema? Sounds like an encoding problem?
    – Callie J
    Nov 9, 2011 at 14:07

1 Answer 1

1

NVARCHAR does allow Unicode, but what you haven't said is how the inserts are made to the database -- it's entirely possible the translation isn't happening at SQL Server but is happening in the ASP.NET application.

Run SQL Profiler against the database and attempt to store a file with a non-ASCII character and see what is actually being executed against the database. If Profiler shows a translated name, then the problem is within ASP.NET. Otherwise SQL Server is doing something odd.

Check this, and then edit your question to report back results.

2
  • thank you. perhaps my question wasn't the best, but i just had a problem i needed to solve. i did what you suggested (my store went from ASP.NET -> WCF -> ado.net -> MSSQL), and it was converted from step 1. I think the character in question was not in the UTF-8 list of characters. My solution was to store using UTF-8, and adjust the filename on the server to be identical to what is in the database.
    – pearcewg
    Nov 9, 2011 at 16:05
  • The character will be in the UTF-8 character set (every character is in the UTF-8 charset), so it's not that that's lost it. How did the bytes come in from the network? It should be possible to trace whereabouts the translation is happening.
    – Callie J
    Nov 9, 2011 at 21:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.