使用oledbconnection读取Tab文件时从值中删除空格

时间:2018-01-29 11:22:38

标签: c#

以下是我的标签文件

的内容
 Id         ScenarioName                                    MainBatchName               Variable                                    Value   French  Dutch   Italian     Remarks     Project             SubProject          EnvDBQuery
 26345935   85036_Self_Service_API_RedeemRewardsRequest     <LMR_AccountNumber@1_1>     "[PC_AccNum]_2"                             ""      ""      ""      ""          BankCard    CreditProcessing    ""
 26345936   85036_Self_Service_API_RedeemRewardsRequest     <LMR_AccountNumber@1_2>     "[PC_AccNum]_1"                             ""      ""      ""      ""          BankCard    CreditProcessing    ""
 26328357   85036_Self_Service_API_RedeemRewardsRequest     <RRR_MessageVal@1_1>        "Loyalty points processed successfully "    ""      ""      ""      ""          BankCard    CreditProcessing    ""
 26328358   85036_Self_Service_API_RedeemRewardsRequest     <RRR_MessageVal@1_2>        "Loyalty points processed successfully "    ""      ""      ""      ""          BankCard    CreditProcessing    ""

我使用以下代码段来阅读选项卡的内容

string fileName = "abc.tab";
string directoryName = @"D:\myDirectory\";
string connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + directoryName + @";Extended Properties=""text;HDR=NO;IMEX=1;FMT=TabDelimited;CharacterSet=65001""";

OleDbCommand oleCmd = new OleDbCommand();
DataTable dataTbl = new DataTable();
OleDbDataAdapter dataAdapter = new OleDbDataAdapter();
OleDbConnection conn = new OleDbConnection(connString);


   oleCmd.Connection = conn;
   conn.Open();

   oleCmd.CommandText = "SELECT * From [" + fileName + "]";
   dataAdapter.SelectCommand = oleCmd;

   CreateSchemaFile("TabDelimited", directoryName, fileName);
   dataAdapter.Fill(dataTbl);

调用fill方法后,数据表的值为&#34; 成功处理了忠诚度积分&#34;而不是&#34; 忠诚度积分已成功处理&#34;

正在删除字符串值末尾的空格(如果有的话)。

应该做什么才能读取选项卡文件中的值?

0 个答案:

没有答案