public static void InsertInto(SQLInsertCommandModel insert) { DBConnection.OpenConnection(); SqlCommand command = new SqlCommand(); command.Connection = DBConnection.ConnectionString; command.CommandText = "INSET INTO " + insert.Query; command.ExecuteNonQuery(); DBConnection.CloseConnection(); }
public static int[] ImportMembers(string table, string filePath) { int[] successFail = new int[2]; //Read form file try { // Open the text file using a stream reader. using (StreamReader sr = new StreamReader(filePath, Encoding.UTF8)) { // Read the stream to a string, and write the string to the console. String line = sr.ReadLine(); string[] columns = line.Split('\t'); int columnCount = columns.Length; string[] rows; while ((line = sr.ReadToEnd()) != null) { rows = line.Split('\t'); try { SQLInsertCommandModel insert = new SQLInsertCommandModel() { Table = table, Columns = columns, Data = rows }; SQLCommandController.InsertInto(insert); successFail[0]++; } catch (Exception) { successFail[1]++; } } } } catch (Exception e) { MessageBox.Show(e.Message); } return(successFail); }