相关疑难解决方法(0)

IErrorInfo.GetDescription失败时带有E_FAIL(0x80004005).System.Data而数据适配器Fill()

我正在尝试从CSV文件中获取数据,通过使用fill()方法我得到了一个异常idk为什么会出现,请查看代码并建议乐观的answer.note如果参数"s"没有任何空格意味着它工作精细.如果它有空间意味着如何克服它,不建议临时重命名和所有.

/// <summary>
/// Import Function For CSV Delimeted File
/// </summary>
/// <param name="s">File Name</param>
private DataTable Import4csv(string s)
{
    string file = Path.GetFileName(s);
    string dir = Path.GetDirectoryName(s);
    string sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;"
                             + "Data Source=\"" + dir + "\\\";"
                             + "Extended Properties=\"text;HDR=YES;FMT=Delimited\"";
    try
    {
        var objConn = new OleDbConnection(sConnection);
        objConn.Open();
        var ds = new DataSet();
        var da = new OleDbDataAdapter("SELECT * FROM " + file, sConnection);
        da.Fill(ds);        // getting exception on this line.
        objConn.Close();
        return ds.Tables[0];
    }
    catch (Exception …
Run Code Online (Sandbox Code Playgroud)

.net c# excel-2007

3
推荐指数
2
解决办法
3万
查看次数

标签 统计

.net ×1

c# ×1

excel-2007 ×1