Getting “Cannot find installable ISAM” error

岁酱吖の 提交于 2019-12-25 02:18:08

问题


I'm facing a problem with my console application. I want to read info from Microsoft Access database and display it on console. Here's the code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.OleDb;
using System.Data.Sql;

namespace _1_uzd
{
    class Program
    {
        static void Main(string[] args)
        {
            string ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;DataSource=\"studentu-db.accdb\"";
            OleDbConnection con = new OleDbConnection(ConnectionString);
            OleDbCommand cmd = new OleDbCommand("SELECT * FROM persona", con);
            con.Open();
            OleDbDataReader dataReader = cmd.ExecuteReader();
            while (dataReader.Read())
            {
                Console.WriteLine(dataReader.GetInt32(0) + "\t" + dataReader.GetString(1) + "\t" + dataReader.GetString(2));
            }
            con.Close();
            Console.ReadLine();
        }
    }
}

It should work but when I debug, the error message is shown: "OleDbExeption was unhandled. Could not find installable ISAM"...Where is the problem?

PS: I'm using Microsoft Access 2007, it that makes any sense,


回答1:


your connection string is not proper. that is main reason this error comes.

Try to correct connection string syntax as per http://www.connectionstrings.com/access/

Try with physical path like "C:\studentu-db.accdb" and if you are trying to locate access database from local folder then write "|DataDirectory|\studentu-db.accdb"



来源:https://stackoverflow.com/questions/21645013/getting-cannot-find-installable-isam-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!