关于TXT文件导入到DATASET中的问题。
大家好,我想讲TXT文件先FILL到DATASET中,获取TXT文件的数量,然后再用SqlBulkCopy将数据写入SQL数据库,现在将TXT数据FILL到DATASET时,FILL那句报错”找不到可安装的 ISAM。“,麻烦各位帮忙指点一下,多谢大家。
OpenFileDialog dlg = new OpenFileDialog();
dlg.Title = "请选择要导入的文件:";
dlg.Filter = "文本文件(*.txt)|*.txt|所有文件|*.*";
dlg.Multiselect = true;
if (dlg.ShowDialog() == DialogResult.OK)
{
string[] FileNames = dlg.FileNames;
foreach (string FileName in FileNames)
{
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data?Source=" + FileName + ";Extended?Properties=Text";
OleDbConnection conn = new OleDbConnection(strConn);
DataSet DS = new DataSet();
OleDbDataAdapter adapter = new OleDbDataAdapter("select * from " + FileName, conn);
OleDbCommandBuilder builder = new OleDbCommandBuilder(adapter);
adapter.Fill(DS,"x");
MessageBox.Show(DS.Tables[0].Rows.Count.ToString());
}
}