且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

需要一个C#从.accdb数据库中获取行的工作示例

更新时间:2022-03-17 00:37:20

using System.Data.OleDb;





string connection = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=yourpath\10_stars.accdb";
using (OleDbConnection con = new OleDbConnection(connection))
{
    con.Open();
    OleDbCommand cmd = new OleDbCommand("SELECT * FROM stars", con);
    OleDbDataReader reader = cmd.ExecuteReader();
}



发布代码后进行编辑.
您的连接字符串不完整.您的SQL语句不包含要从中提取数据的表的名称.



Edit after your code posted.
Your connection string is incomplete. Your SQL statement does not include the name of the table to extract the data from.