Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I don't have much experience with MS SQL server 2008 R2 but here is the issue if you would help me please:
I have a table with a column/field (type : nvarchar) that stores text. The text is read from a text file and written to the database using vb.net application.
The text in the text file contains Turkish characters such as the u with 2 dots on top(in the future it will be in different languages )
When I open the table, the text in the column is not readable. It converts the Turkish special character to some unreadable characters.
Is there anyway to make the text readable in the table?
Thank you so much.
Posted

1 solution

The first three bytes of the text files show the encoding. From the symptoms you describe, the encoding is not unicode, but a specialized encoding (Windows-1250 or something like that).
The VB application must convert the text from that encoding to unicode before storing the data in the database.
 
Share this answer
 
Comments
jad0521 24-Jan-12 0:05am    
I modified the code so it reads from a CSV file and writes to another CSV file (excel file saved as .csv). I pasted the code bellow because I don't know how to attach a zip file here. Try copy and paste these characters into the original .csv file: ú ü ø ? ? Ñ Ö æ ä å ã ë ( modify the file path as necessary)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.IO;
using System.Security;
using System.Xml;
using System.Data.SqlClient;
using Microsoft.VisualBasic.FileIO;

namespace FileWatcher
{
public partial class FileWatcher : ServiceBase
{
DateTime lastRead = DateTime.MinValue;

public FileWatcher()
{
InitializeComponent();

try
{
if (!System.Diagnostics.EventLog.SourceExists("FileWatcher"))
{
System.Diagnostics.EventLog.CreateEventSource("FileWatcher", "FileWatcher.Log");
}
FileWatcherEventLog.Source = "FileWatcher";
FileWatcherEventLog.Log = "FileWatcher.Log";
}
catch (SecurityException e)
{
throw (e);
}
}

protected override void OnStart(string[] args)
{
FileWatcherEventLog.WriteEntry("FileWatcher() starting...");
watch();
}

protected override void OnStop()
{
FileWatcherEventLog.WriteEntry("FileWatcher() stopping...");
watcher.Dispose();
}

private void watch()
{
try
{
//set path and filename
// watcher.Path = @"C:\DataTrakInsights\CustomerData\ProscapeCloud\DataTrakImports\";
watcher.Path = @"C:\Users\jawad\Desktop\FileWatcherTestFolder\";
watcher.Filter = "*.csv";

//handle file created event
watcher.Created += new FileSystemEventHandler(watcher_Changed);
watcher.EnableRaisingEvents = true;

FileWatcherEventLog.WriteEntry("Now watching " + watcher.Path);
}
catch (Exception e)
{
FileWatcherEventLog.WriteEntry(e.Message);
}

}

private void FileWatcherEventLog_EntryWritten(object sender, EntryWrittenEventArgs e)
{

}

private void watcher_Changed(object sender, FileSystemEventArgs e)
{
if (e.ChangeType == WatcherChangeTypes.Created)
{
DateTime lastWriteTime = File.GetLastWriteTime(e.FullPath);
if (lastWriteTime != lastRead)
{

DateTime fileReceived = DateTime.Now;

while (true)
{
if (FileUploadCompleted(e.FullPath))
{
try
{
//log file change
FileWatcherEventLog.WriteEntry(e.FullPath + " " + e.ChangeType);

//run parser
parse(e.FullPath);
}
catch (Exception ex)
{
FileWatcherEventLog.WriteEntry(ex.Message);
}

break;
}
// Calculate the elapsed time and stop if the maximum retry
// period has been reached.
TimeSpan timeElapsed = DateTime.Now - fileReceived;

if (timeElapsed.TotalMinutes > 3000000)
{
FileWatcherEventLog.WriteEntry("The file " + e.FullPath + " could not be proces

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900