string script =
"INSERT INTO DEPT VALUES (10,'ACCOUNTING','NEW YORK');"+
"INSERT INTO DEPT VALUES (20,'RESEARCH','DALLAS');"+
"INSERT INTO DEPT VALUES (30,'SALES','CHICAGO');"+
"INSERT INTO DEPT VALUES (40,'OPERATIONS','BOSTON');"+
"SELECT * FROM DEPT";
SQLiteConnection sqConn = new SQLiteConnection(
"DataSource=mydatabase.db;");
SQLiteScript sqScript = new SQLiteScript(script,sqConn);
SqlStatementCollection sqColl = sqScript.Statements;
IDataReader sqReader;
sqConn.Open();
foreach (SqlStatement sqStatement in sqColl)
{
Console.WriteLine(sqStatement.Text);
try
{
sqReader = sqStatement.Execute();
Console.WriteLine(" Records affected " + sqReader.RecordsAffected);
while (sqReader.Read())
{
Console.WriteLine(sqReader.GetString(0));
}
sqReader.Close();
Console.WriteLine();
}
catch
{
Console.WriteLine(" Failed");
}
}
sqConn.Close();