System.Data.OleDb.OleDbException: '找不到可安裝的 ISAM。'

黃宏軒




input_newfile = "C:\TUH.xls";

DataSet ds;
            string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;" +
                            "Extended  Properties=Excel 8.0;'Excel 8.0;HDR=Yes;IMEX=1'" +
                            "data source=" + input_newfile;
            OleDbConnection myConn = new OleDbConnection(strCon);
            string strCom = " SELECT * FROM [Sheet1$]";
            myConn.Open();
            OleDbDataAdapter myCommand = new OleDbDataAdapter(strCom, myConn);
            ds = new DataSet();
            myCommand.Fill(ds);
            myConn.Close();


在myConn.Open();的地方報錯 求解...

最有價值解答

Edward
strCon 修改成

            string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;"
                              + "data source=" + input_newfile + ";" +
                               "Extended Properties='Excel 8.0;HDR=Yes;IMEX=1;'";


應該就可以了
MIS2000 Lab
原PO的第五列的最後,少了分號(;)

"Extended Properties=Excel 8.0;'Excel 8.0;HDR=Yes;IMEX=1'" + ";" +
回到頂部