none
how I can import UTF-8 text file to access with c#? RRS feed

  • Question

  • how I can import UTF-8 text file ?

    when I import text file to access database with this code, It don't save with correct format
    example :آباد save  ´ظ†ط§طŒ)
                 try  
                {  
                    using  (OleDbConnection conn =   
                        new  OleDbConnection(@ "provider=microsoft.jet.oledb.4.0;data source=C:\Newsgroups\Database1.mdb" ))  
                    {  
                        conn.Open();  
                        using  (OleDbCommand cmd = conn.CreateCommand())  
                        {  
                            try  
                            {  
                                cmd.CommandText = "drop table MyLocalTable" ;  
                                cmd.ExecuteNonQuery();  
                            }  
                            catch  (Exception)   
                            {   
                                // Don't care if target table exists, going to copy into it.  
                            }  
     
                            cmd.CommandText = @"SELECT * INTO MyLocalTable FROM [Text;FMT=Delimited;HDR=NO;IMEX=2;DATABASE=C:\Newsgroups].[Customers.txt]" ;  
                            cmd.CommandType = CommandType.Text;  
                            cmd.ExecuteNonQuery();  
                        }  
                    }  
                }  
                catch  (Exception ex)  
                {  
                    MessageBox.Show(ex.Message);  
                } 
    Tuesday, December 21, 2010 9:23 AM

Answers