Question Funny characters after importing data using OLEDB

kasteel

Well-known member
Joined
May 29, 2009
Messages
50
Programming Experience
10+
Hi

When I import data into Excel from a text file (text or general column in excel) it imports some of the characters into funny characters. Example, the - sign in the text file will be converted to – in Excel.

VB.NET:
Public Sub ExcelImport()
        'Import Output file to Excel
        Dim ImportFileExists As String = "C:\test\mytextfile.txt

        If System.IO.File.Exists(ImportFileExists) = True Then

            Dim ExcelConnection As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
            "Data Source=c:\excelfile.xls;Extended Properties=""Excel 8.0;HDR=YES;FMT=TabDelimited""")

            ExcelConnection.Open()
            Dim ImportCommand As New System.Data.OleDb.OleDbCommand("INSERT INTO [Sheet1$] (Photo,Student_ID,Name,Surname,Faculty,Department,Supervisor,Submission_Type,Submission_Title,Abstract,Phone,Email,Include_Email) SELECT * FROM [Text;HDR=YES;DATABASE=c:\test].[mytextfile.txt]", ExcelConnection)
            ImportCommand.ExecuteNonQuery()
            ExcelConnection.Close()
        Else
            Return
        End If
    End Sub

Any idea how I can fix this or prevent it from happening? Any help would be appreciated.

Thanks
 
Back
Top