private void btnLoadData_Click(object sender, EventArgs e) { // This disables a couple of buttons and/or text boxes to be sure that an exception won't happen. btnExecute.Enabled = true; btnLoadData.Enabled = false; btnSelectFile.Enabled = false; txtQuery.Enabled = true; txtPath.Enabled = false; // This is letting us to load in a CSV file. // TblTeams: if ((txtPath.Text != null && rb_Teams.Checked == true)) { string dropTableTeams = "DROP TABLE TblTeams "; string createTableTeams = "CREATE TABLE TblTeams(" + " Team_id INT NOT NULL," + " poule_id INT NULL," + " Teamname VARCHAR(255) NULL," + " created_at VARCHAR(255) NULL," + " deleted_at VARCHAR(255) NULL," + ");"; string insertTableTeams = "BULK INSERT TblTeams" + " FROM '" + txtPath.Text + "'" + "WITH" + "(" + " FIRSTROW = 2," + " FIELDTERMINATOR = ',', " + " ROWTERMINATOR = '\n', " + " TABLOCK" + ");"; dbh.TestConnection(); ExecuteSQL(dropTableTeams); dbh.ExecuteAdmin(createTableTeams); dbh.ExecuteAdmin(insertTableTeams); } else { // This shows a message if nothing is selected. MessageHandler.ShowMessage("No filename selected."); } // TblGames: if ((txtPath.Text != null && rb_Games.Checked == true)) { string dropTableGames = "DROP TABLE TblGames "; string createTableGames = "CREATE TABLE TblGames" + "(" + "Game_id VARCHAR(255) NOT NULL," + "HomeTeam VARCHAR(255) NOT NULL," + "AwayTeam VARCHAR(255) NOT NULL," + "HomeTeamScore VARCHAR(255) NULL," + "AwayTeamScore VARCHAR(255) NULL" + ");"; string insertTableGames = "BULK INSERT TblGames" + " FROM '" + txtPath.Text + "'" + "WITH" + "(" + " FIRSTROW = 2," + " FIELDTERMINATOR = ',', " + " ROWTERMINATOR = '\n', " + " TABLOCK" + ");"; dbh.TestConnection(); ExecuteSQL(dropTableGames); dbh.ExecuteAdmin(createTableGames); dbh.ExecuteAdmin(insertTableGames); } else { // This shows a message if nothing is selected. MessageHandler.ShowMessage("No filename selected."); } }