DataSourcesTableAdapters 连接到 SQLite

DataSourcesTableAdapters connection to SQLite

对于我的 VB.Net 项目,我正在尝试添加对 SQLite 数据库的支持。我已经通过 NuGet 和 VS 2010 安装了 System.Data.SQLite.dll。

我可以成功连接到 SQLite 数据库并且 运行 可以直接针对它进行一些查询。但是,我无法将任何数据加载到我的 DataSourcesTableAdapters 中。我在尝试填充数据 table.

时立即收到 "The 'System.Data.SQLite' provider is not registered on the local machine." 错误

当我使用我原来的 MS Access 数据文件时一切正常。

目标 CPU 是 x86

System.Data.SQLite.dll复制到本地app文件夹

Stack Trace:
   at System.Data.OleDb.OleDbServicesWrapper.GetDataSource(constr As OleDbConnectionString, datasrcWrapper As DataSourceWrapper&)
   at System.Data.OleDb.OleDbConnectionInternal..ctor(constr As OleDbConnectionString, connection As OleDbConnection)
   at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(options As DbConnectionOptions, poolGroupProviderInfo As Object, pool As DbConnectionPool, owningObject As DbConnection)
   at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(owningConnection As DbConnection, poolGroup As DbConnectionPoolGroup)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnection(owningConnection As DbConnection)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(outerConnection As DbConnection, connectionFactory As DbConnectionFactory)
   at System.Data.OleDb.OleDbConnection.Open()
   at System.Data.Common.DbDataAdapter.QuietOpen(connection As IDbConnection, originalState As ConnectionState&)
   at System.Data.Common.DbDataAdapter.FillInternal(dataset As DataSet, datatables As DataTable[], startRecord As Int32, maxRecords As Int32, srcTable As String, command As IDbCommand, behavior As CommandBehavior)
   at System.Data.Common.DbDataAdapter.Fill(dataTables As DataTable[], startRecord As Int32, maxRecords As Int32, command As IDbCommand, behavior As CommandBehavior)
   at System.Data.Common.DbDataAdapter.Fill(dataTable As DataTable)
   at LisanoEnterprises.GrandPrix.DataSourcesTableAdapters.RostersTableAdapter.GetDataByRound(Round As Int32)
   at LisanoEnterprises.GrandPrix.ReportCtrl.ViewRosters(objReportCriteria As ReportCriteria)
   at LisanoEnterprises.GrandPrix.frmReports.ViewRoster()
   at LisanoEnterprises.GrandPrix.frmReports.ViewReport(iCategory As Int32, iReportNum As Int32)
   at LisanoEnterprises.GrandPrix.frmReports.btnMainView_Click(sender As Object, e As EventArgs)

Exception Hierarchy:
Top Level   System.InvalidOperationException    Void GetDataSource(System.Data.OleDb.OleDbConnectionString, System.Data.OleDb.DataSourceWrapper ByRef)
    The 'System.Data.SQLite' provider is not registered on the local machine.

我已经设法解决了这个问题。我没有使用 table 适配器,而是从数据 reader.

加载数据 table
  Dim reader As IDataReader = _dbCtrl.ExecuteReader(sSQL)
  Dim dt As New DataTable

  dt.Load(reader)

  reader.Close()