Created
February 27, 2018 05:57
-
-
Save talkingdotnet/d050970162908fe45e103a2d954cb972 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void DisableForeignKey(bool flag) | |
{ | |
string query = ""; | |
if (flag) | |
query = "SET FOREIGN_KEY_CHECKS=0;"; | |
else | |
query = "SET FOREIGN_KEY_CHECKS=1;"; | |
try | |
{ | |
using (MySqlConnection connection = new MySqlConnection(_connectionString)) | |
{ | |
using (MySqlCommand command = new MySqlCommand()) | |
{ | |
connection.Open(); | |
command.Connection = connection; | |
command.CommandText = query; | |
command.ExecuteNonQuery(); | |
} | |
} | |
} | |
catch (Exception ex) | |
{ | |
WriteToConsole("Error: DisableForeignKey()" + "\n" + ex.ToString()); | |
throw ex; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment