阅读在C#中.db文件 [英] read a .db file in C#

查看:269
本文介绍了阅读在C#中.db文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 string Path = @"c:\Database\Mydatabase.db";

     string myConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path + ";Extended Properties=Paradox 5.x;";

    // Define the database query    
    string mySelectQuery = "SELECT id,name FROM people WHERE id < 3;";

    // Create a database connection object using the connection string    
    OleDbConnection myConnection = new OleDbConnection(myConnectionString);

    // Create a database command on the connection using query    
    OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection);

    // Open the connection    
    myCommand.Connection.Open();

    // Create a database reader    
    OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

该错误是myCommand.Connection.Open();它说: C:\数据库\ Mydatabase.db'不是一个有效的路径。确保路径名称是否正确,并且您连接到该文件所在的服务器拼写。

The Error is at myCommand.Connection.Open(); and it says: 'c:\Database\Mydatabase.db' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.

我想读在C#中的.db文件。不过,我得到一个错误,我相信,文件位于那里的错误是没有道理给我。请你帮助我好吗 ?或者,我怎么能读一个.db的(矛盾)数据库在C#中的文件?

I am trying to read a .db file in C#. However, I am getting an error, I am sure that file is located there, the error does not make sense for me. Could you please help me ? Or How can I read a .db(paradox) database file in C# ?

编辑: 字符串路径= @C:\数据库\;

string Path = @"c:\Database\";

对于这种情况下的错误是Microsoft Jet数据库引擎找不到对象'人'。请确保该对象存在并且您拼写其名称和路径名称。

The Error for this case is "The Microsoft Jet database engine could not find the object 'people'. Make sure the object exists and that you spell its name and the path name correctly."

如果我改变它这样,如何​​C#查找数据库文件会被使用?一直以来,我没有指定的文件名是Mydatabase.db在任何地方

If I change it like that, How can C# find which database file is gonna be used ? Since, I did not specify file name which is "Mydatabase.db" at anywhere

推荐答案

确认这是一个SQLite数据库,我只是下载了它在我的手机和一个SQLite观众观看了它。

Confirmed it is an SQLite database, I just downloaded it on my phone and viewed it with an SQLite viewer.

您需要下载一个ADO.NET提供者SQLite的:

You will need to download an ADO.NET provider for SQLite:

官方版本(从SQLite的,而不是MS)

"Official" version (from SQLite, not MS)

HTTP://system.data.sqlite。组织/ index.html的/ DOC /主干/网络/ index.wiki

旧版本

http://sqlite.phxsoftware.com/

这篇关于阅读在C#中.db文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆