读取 csv Oldb c#

Read csv Oldb c#

我在打开 csv 文件时遇到问题我有错误 "not found ISAM"。我尝试将线路更改为连接,但没有发现错误。我该如何解决?

    private void button7_Click(object sender, EventArgs e)
    {
        openFileDialog1.Filter = "CSV|*.csv";
        openFileDialog1.ValidateNames = true;
        openFileDialog1.Multiselect = true;
        if (openFileDialog1.ShowDialog() == DialogResult.OK)
            textBox2.Text = openFileDialog1.FileName;
    }

    private void button8_Click(object sender, EventArgs e)
    {
        try
        {
            // string stringconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + textBox2.Text + ";Extended Properties=\"Text;HDR=Yes;FORMAT=Delimited\"";
            string stringconn = "Provider=Microsoft.Jet.OLEDB.4.0;DataSource=" + textBox2.Text + ";Extended Properties=text;HDR=Yes;FMT=Delimited";
            string file = System.IO.Path.GetFileName(textBox2.Text);
            OleDbConnection cons = new OleDbConnection(stringconn);
            OleDbDataAdapter dat = new OleDbDataAdapter("Select * from" + file, cons);
            dat.Fill(dt);
            dataGridView1.DataSource = dt;
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
string stringconn = "Provider=Microsoft.Jet.OLEDB.4.0;DataSource=" + textBox2.Text + ";Extended Properties='text;'";

尝试为 Extended Propetries 的值添​​加单引号