得到“找不到可安装的ISAM".错误 [英] Getting "Cannot find installable ISAM" error
问题描述
我的控制台应用程序遇到问题.我想从Microsoft Access数据库中读取信息并将其显示在控制台上. 这是代码:
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();
}
}
}
它应该可以工作,但是当我调试时,会显示错误消息:"OleDbExeption未处理.找不到可安装的ISAM" ...问题出在哪里?
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:我正在使用Microsoft Access 2007,这有任何意义,
PS: I'm using Microsoft Access 2007, it that makes any sense,
推荐答案
您的连接字符串不正确.这是导致此错误的主要原因.
your connection string is not proper. that is main reason this error comes.
尝试按照 http://www.connectionstrings.com/access/
尝试使用"C:\ studentu-db.accdb"之类的物理路径,如果您尝试从本地文件夹中找到访问数据库,请输入"| DataDirectory | \ studentu-db.accdb"
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"
这篇关于得到“找不到可安装的ISAM".错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!