public static bool createDataBase(String PCname, String DBname, String path) { dbCreater = new DBCreater(DBname, path); bool f = false; StringBuilder sb = new StringBuilder("server = "); sb.Append(PCname).Append("; Integrated Security = true"); try { SqlConnection sqlConnection = new SqlConnection(sb.ToString()); SqlCommand sql = new SqlCommand(dbCreater.getCreateDBSting(), sqlConnection); sqlConnection.Open(); sql.ExecuteReader(); sqlConnection.Close(); f = true; SQLWorker w = new SQLWorker(PCname, DBname); f = addNewTables(w) && addStoreProc(w); } catch (System.Exception ex) { Console.WriteLine(ex); return(false); } dbCreater = null; return(f); }
private static bool addNewTables(SQLWorker worker) { bool f = false; try { List <String> list = dbCreater.getList(); SqlConnection con = worker.GetSqlConnection(); foreach (String str in list) { SqlCommand sql = new SqlCommand(str, con); con.Open(); sql.ExecuteReader(); con.Close(); } f = true; } catch (System.Exception ex) { Console.WriteLine(ex); return(false); } return(f); }