I've created a dump file from a Sqlite database and I want to create another sqlite database based on this file in my C#
application.
a sample of the dump file:
drop table if exists [main].[tblAyah];
CREATE TABLE [main].[tblAyah] (
[IdAyah] INTEGER NOT NULL PRIMARY KEY ON CONFLICT REPLACE AUTOINCREMENT,
[AyahNumber] INTEGER,
[Page] INTEGER);
insert into [main].[tblAyah] values(1, 1, 1, 'somthing','somthing');
...
So My question is:
Is there a particular way to do that or I just have to read the file as string and run each command line one by one like this:
IEnumerable<string> tblCommand;
//Reading the dump file line by one and adding to tblCommand
using (SqlCeConnection con = new SqlCeConnection(
"DataSource=\"|DataDirectory|\\newDb.db\";Persist Security Info=False;"))
{
con.Open();
foreach (string command in tblCommand)
using (SqlCeCommand com =
new SqlCeCommand(command, con))
{
com.ExecuteNonQuery();
}
con.Close();
}
Aucun commentaire:
Enregistrer un commentaire