public DatabaseLinks() { try { DBCredential dbc = new DBCredential(); string csting = dbc.Read(Properties.Settings.Default.DBString); dataset = new System.Data.DataSet(); this.dataset.Tables.Add("TaskTable"); this.dataset.Tables.Add("TaskRelation"); this.dataset.Tables.Add("TaskPredcessor"); this.dataset.Tables.Add("Calendar"); connection.ConnectionString = csting; string projcode = "'" + Properties.Settings.Default.ProjectCode.Replace(",", "','") + "'"; getSqlTable(this.dataset.Tables["TaskTable"], string.Format(Properties.Settings.Default.Tasks, projcode)); getSqlTable(this.dataset.Tables["TaskRelation"], string.Format(Properties.Settings.Default.TaskUnique, projcode)); getSqlTable(this.dataset.Tables["TaskPredcessor"], string.Format(Properties.Settings.Default.TaskPredecessor, projcode)); getSqlTable(this.dataset.Tables["Calendar"], string.Format(Properties.Settings.Default.Calendar, projcode)); try { this.TaskRelation.Constraints.Add("PK", new System.Data.DataColumn[] { this.TaskRelation.Columns["task_id"], this.TaskRelation.Columns["proj_id"] }, true); this.dataset.Relations.Add("PCrel", new System.Data.DataColumn[] { this.TaskRelation.Columns["task_id"], this.TaskRelation.Columns["proj_id"] }, new System.Data.DataColumn[] { this.TaskPredcessor.Columns["task_id"], this.TaskPredcessor.Columns["proj_id"] }); } catch (Exception exp) { System.Windows.Forms.MessageBox.Show(exp.Message); } } catch (Exception exp) { System.Windows.Forms.MessageBox.Show(exp.Message); } }
private void Generate_Click(object sender, EventArgs e) { string DBString = string.Format("Server={0};Database={1};User ID={2};Password={3};Trusted_Connection=False;", new string[] { textServer.Text, textDatabase.Text, textUser.Text, textPassword.Text }); DBCredential dbc = new DBCredential(); Properties.Settings.Default.DBString = dbc.GenerateDBCredential(DBString); Properties.Settings.Default.Save(); this.Close(); }