Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

SQlite script

string script = File.ReadAllText(@"E:someSqlScript.sql");

// split script on GO command
IEnumerable<string> commandStrings = Regex.Split(script, @"^s*GOs*$", RegexOptions.Multiline | RegexOptions.IgnoreCase);

Connection.Open();
foreach (string commandString in commandStrings)
{
    if (!string.IsNullOrWhiteSpace(commandString.Trim()))
    {
        using(var command = new SqlCommand(commandString, Connection))
        {
            command.ExecuteNonQuery();
        }
    }
}     
Connection.Close();
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #SQlite #script
ADD COMMENT
Topic
Name
9+1 =