I am doing a SQL table data copy. First I am getting all the data from a csv file (which is got from a sql table) in the csv file I get ‘é’ correctly, but when I insert it in the table then I’m getting ‘?’ in the sql table. I don’t use any encoding, so everything is default. Somebody knows why this happens?
SOLVED:
Needed to read the csv like this:
string[] csvlines = File.ReadAllLines("C:\\export.csv",Encoding.GetEncoding("Windows-1252"));
Thanks
Generally speaking you should use whatever encoding was used when the table was created (or last modified – for the nitpickers).
If you are transferring data between different tables you possibly need to use different encodings for reading and writing data.
The .NET framework provides a rich list of implemented encodings, which you can find below this type: System.Text.Encoding
UPDATE
Please use Notepad++ to determine the encoding of the .CSV-file you are reading data from. Then use that Encoding in the constructor of your StreamReader object.
So if Notepad++ tells you that the file is encoded in UTF-8, use the following lines of code to read from your file: