private void btnCrearFuncion_Click(object sender, EventArgs e) { if (!txtNombreFuncion.Text.Equals(String.Empty) && !rtbDefinicion.Equals(String.Empty)) { try { string crearFuncion = "CREATE FUNCTION " + txtNombreFuncion.Text + "(" + listaEntradas() + ")" + " RETURNS " + cbTipoRetorno.SelectedItem + " AS $BODY$ " + rtbDefinicion.Text + " $BODY$ LANGUAGE 'plpgsql' VOLATILE;"; Console.WriteLine(crearFuncion); bool funcion = bdbol.Consulta(crearFuncion, database); if (funcion) { MessageBox.Show("Funcion creada"); this.Dispose(); } else { MessageBox.Show("No se pudo crear la funcion"); } CargarFunciones(); } catch (Exception ex) { CargarFunciones(); MessageBox.Show(ex.Message); } } }
private void button1_Click(object sender, EventArgs e) { try { Char[] cont; string consulta = rtboxConsulta.Text.Trim(); cont = consulta.ToCharArray(); string s = cont[0].ToString() + cont[1].ToString() + cont[2].ToString() + cont[3].ToString() + cont[4].ToString() + cont[5].ToString(); NpgsqlDataAdapter a = dbbol.ConsultaSelect(consulta, cbBases.SelectedItem.ToString()); if (s.ToLower().Equals("select")) { Tables t = new Tables(cbBases.SelectedItem.ToString(), consulta); t.Show(); } else if (a != null) { Tables t = new Tables(a); t.Show(); } else if (dbbol.Consulta(consulta, cbBases.SelectedItem.ToString())) { rcOutPut.Text = "Query successfully complete"; ActualizarArbol(); } dbbol.CerrarConsulta(); } catch (Exception ex) { dbbol.CerrarConsulta(); rcOutPut.Text = ex.Message; } }
private void button1_Click(object sender, EventArgs e) { try { Char[] cont; string consulta = String.Format("CREATE SEQUENCE public.\"{0}\"" + "INCREMENT {1}" + "START {2}" + "MINVALUE {3}" + "MAXVALUE {4}" + ";" + "ALTER SEQUENCE public.\"{5}\"" + "OWNER TO postgres;", txtNombre.Text, txtIncrement.Text, txtStart.Text, txtMinValue.Text, txtMaxValue.Text, txtNombre.Text); cont = consulta.ToCharArray(); string s = cont[0].ToString() + cont[1].ToString() + cont[2].ToString() + cont[3].ToString() + cont[4].ToString() + cont[5].ToString(); if (dbbol.Consulta(consulta, cbBases.SelectedItem.ToString())) { MessageBox.Show("Sequence Created"); clearInfo(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnCrearVista_Click(object sender, EventArgs e) { try { string vista = "CREATE VIEW " + txtNombreVista.Text + " AS " + rtbCrearVista.Text; bool vistacreada = bdbol.Consulta(vista, database); if (vistacreada) { MessageBox.Show("Vista creada"); } else { MessageBox.Show("No se pudo crear la vista"); } CargarCombos(); } catch (Exception ex) { MessageBox.Show(ex.Message); CargarCombos(); } }
private void button1_Click(object sender, EventArgs e) { try { Char[] cont; string consulta = String.Format("CREATE SCHEMA {0} " + "AUTHORIZATION postgres; ", txtSquemaName.Text); cont = consulta.ToCharArray(); string s = cont[0].ToString() + cont[1].ToString() + cont[2].ToString() + cont[3].ToString() + cont[4].ToString() + cont[5].ToString(); if (dbbol.Consulta(consulta, cbBases.SelectedItem.ToString())) { MessageBox.Show("Squema Created Succesfully"); txtSquemaName.Text = ""; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }