我目前正在C#與sqlite數據庫。我正在使用Community.CsharpSqlite來連接應用程序和數據庫。我希望能夠在sqlite上使用ATTACH命令來安裝另一個數據庫。使用ATTACH與社區.CsharpSqlite
https://www.nuget.org/packages/Community.CsharpSqlite.SQLiteClient/
我能夠做到這一點使用System.Data.Sqlite,但我想知道是否有人知道如何與Community.CsharpSqlite使用它。
目標:查詢大型數據庫並將結果存儲在子數據庫中。
計劃:將大數據庫,數據庫子的連接,使用
連網「大數據庫」作爲ToMerge; (在子DB的連接中)
插入表中選擇* from ToMerge.table;
這是我使用System.Data.Sqlite
public static void importData(String fileLoc)
{
string SQL = "ATTACH '" + fileLoc + "' AS TOMERGE";
SQLiteConnection con = new SQLiteConnection("Data Source = D:\\sqirl_test\\ir1.db;Version=3");
con.Open();
SQLiteCommand cmd = new SQLiteCommand(SQL, con);
int retval = 0;
try
{
retval = cmd.ExecuteNonQuery();
}
catch (Exception)
{
Console.WriteLine("An error occurred, your import was not completed.");
}
finally
{
cmd.Dispose();
}
SQL = "INSERT INTO IMAGEREPOSITORY SELECT * FROM TOMERGE.IMAGEREPOSITORY";
cmd = new SQLiteCommand(SQL, con);
retval = 0;
try
{
retval = cmd.ExecuteNonQuery();
}
catch (Exception)
{
Console.WriteLine("An error occurred, your import was not completed.");
}
finally
{
cmd.Dispose();
con.Close();
}
}
什麼問題呢? –
我想使用Community.CsharpSqlite端口來做到這一點。沒有適當的文件,所以想知道這裏有沒有人做過。 –