我试图从不同的位置加入SQLite数据库;
folder1 =我的主数据库所在的位置。
folder2 =我本地C的某个地方。
这是我到目前为止所做的,但我没有运气。我觉得错过了什么?
internal void Fill_DataCollection(string folder2)
{
string SQL = "ATTACH '" + folder2 + "' AS db2";
SQLiteCommand cmd = new SQLiteCommand(SQL);
string connectionString = string.Format("Data Source={0}", folder1 .databasePath);
using (var conn = new SQLiteConnection(connectionString))
{
conn.Open();
cmd.Connection = conn;
cmd.CommandText = string.Format("SELECT * FROM tblMain A inner join db2.tblSub B on B.ID = A.ID");
var _dataAdapter = new SQLiteDataAdapter(cmd.CommandText, cmd.Connection);
DataSet _dataSet = new DataSet();
DataTable _dataTable = new DataTable();
_dataSet.Reset();
_dataAdapter.Fill(_dataSet);
_dataTable = _dataSet.Tables[0];
var rows = _dataTable.Rows; ;
foreach (DataRow row in rows)
{
var reportID = row.ItemArray[1];
string status = row.ItemArray[3] as string;
string vendorStatus = row.ItemArray[3] as string;
var TechdataProperties = new TechdataProperties
{
ReportID = reportID.ToString(),
Status = status,
VendorStatus = vendorStatus,
};
_techdataCollection.Add(TechdataProperties);
}
conn.Close();
}
}
此代码出错:
SQLite错误(1):没有这样的表:db2.tblSub