问题描述
- C#读取dbf文件,更改字段的encoding后,全部记录写入新的dbf
-
怎么导出的数据时完全重复的9条记录,xmldataset里面只有6条,求解
以下为Array类型变量list值
[0] "ID" object {string}
[1] "SUP_CODE" object {string}
[2] "SUP_NAME" object {string}
[3] "SUP_CNAME" object {string}
[4] "BARCODE" object {string}
[5] "NAME" object {string}
[6] "PRDT_DESC" object {string}
[7] "UNITE" object {string}
[8] "BRAND" object {string}
[9] "PACK" object {string}
[10] "SIZE" object {string}
[11] "PRICE" object {string}
[12] "DEPT_NO" object {string}
[13] "PRDT_GRP" object {string}
[14] "DEPT_NAME" object {string}
[15] "OWNLABEL" object {string}foreach (DataRow row in xmlDataSet.Rows)//将数据导出到DBF文件中
{string insertSql = "insert into [T" + fileName + "] values("; for (int i = 0; i < list.Count; i++) { insertSql += "@" + list[i].ToString() + ","; OleDbParameter para = new OleDbParameter("@" + list[i].ToString(), OleDbType.VarChar, 50); byte[] temp = Encoding.Default.GetBytes(row[list[i].ToString()].ToString()); temp = Encoding.Convert(Encoding.GetEncoding("big5"), Encoding.GetEncoding("gb2312"), temp); string temp1 = Encoding.Default.GetString(temp); cmd.Parameters.Add(para); para.Value = temp1; } insertSql = insertSql.Substring(0, insertSql.Length - 1) + ")"; cmd.CommandText = insertSql; cmd.ExecuteNonQuery(); }
时间: 2024-12-01 22:27:26