private void button2_Click(object sender, EventArgs e) { if (cbDatabaza.SelectedItem.ToString() == "MSSQL") { string text1 = ""; string text2 = ""; text1 = "server="+db1Server.Text+";database="+db1Name.Text+";uid="+db1Username.Text+";pwd="+db1Pass.Text+";MultipleActiveResultSets=True;"; text2 = "server=" + db2Server.Text + ";database=" + db2Name.Text + ";uid=" + db2Username.Text + ";pwd=" + db2Pass.Text + ";MultipleActiveResultSets=True;"; ConnectionMSSQL con1 = new ConnectionMSSQL(text1); ConnectionMSSQL con2 = new ConnectionMSSQL(text2); if (com.createConnections(con1, con2)) { MessageBox.Show("Connection succesfull"); DBsyncTreeview strom = com.vyrobStromA(); main.aktualizujIkonky(strom); main.getTvDb1().Nodes.Add(strom); DBsyncTreeview strom2 = com.vyrobStromB(); main.aktualizujIkonky(strom2); main.getTvDb2().Nodes.Add(strom2); this.Close(); } else MessageBox.Show("Connection was not succesfull"); } }
public bool vytvorMSSQLpripojenie(string connstring) { ConnectionMSSQL sqlPrip = new ConnectionMSSQL(connstring); prip = sqlPrip; if (sqlPrip.createConnection()) { tabulky = sqlPrip.ReadTables(); procedury = sqlPrip.ReadProcedures(); funkcie = sqlPrip.ReadFunctions(); typy = sqlPrip.ReadTypes(); usery = sqlPrip.ReadUsers(); nameOfDatabase = sqlPrip.GetNameOfDB(); pripAktivne = true; return true; } return false; }