problem with bulkcopy .mdb access file into sqlserver2008

Answered problem with bulkcopy .mdb access file into sqlserver2008

  • Sunday, November 18, 2012 9:33 AM
     
     

    hi...

    here is my code.i have to bulkcopy access .mdb into sqldatabase. my data is persian.when i test this code in my computer it works fine. but when i do this in server(on the web) it works good but al my data format damaged like as "ÝæÞ ÇáÚÇÏå ÓÎÊí ÔÑÇíØãÍíØßÇÑ" ...

    i can't find what this happaned.

    please help me.

    string s = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("~/.../" + fileName);
    OleDbConnection OleDbConn = new OleDbConnection(s);

               

    try
            {
                string sSQLTable = table;

                string myAccessDataQuery = "Select * from " + sSQLTable;

                OleDbCommand OleDbCmd = new OleDbCommand(myAccessDataQuery, OleDbConn);
                OleDbConn.Open();


                OleDbDataReader dr = OleDbCmd.ExecuteReader();
                SqlBulkCopy bulkCopy = 
                    new        SqlBulkCopy(WebConfigurationManager.ConnectionStrings["mySqlConnectionStr"].ToString() ,
                        SqlBulkCopyOptions.KeepIdentity);

                bulkCopy.DestinationTableName = sSQLTable;

                bulkCopy.WriteToServer(dr);

                OleDbConn.Close();
                return "Done";
            }

All Replies