elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Usando Git para manipular el directorio de trabajo, el índice y commits (segunda parte)


  Mostrar Temas
Páginas: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [17] 18 19 20 21 22
161  Programación / Programación C/C++ / cast tipo datePicker a string en: 14 Mayo 2013, 03:06 am
saludos tengo este codigo que me esta dando un error en la parte de buscar, que me tiene que buscar un numero de cuenta y si lo encuentra mostrarme todos los demas datos de la entidad, me dice que no se puede convertir de datePicker a string

Código
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Npgsql;
  10.  
  11. namespace Agencia_de_Viajes
  12. {
  13.    public partial class Form5 : Form
  14.    {
  15.        public Form5()
  16.        {
  17.            InitializeComponent();
  18.        }
  19.  
  20.        private void irMenu_Click(object sender, EventArgs e)
  21.        {
  22.            this.Visible = false;
  23.            Form1 menu = new Form1();
  24.            menu.Visible = true;
  25.        }
  26.  
  27.        private void cmdAgregar_Click(object sender, EventArgs e)
  28.        {
  29.            if (txtNumeroCuenta.Text == "" || txtDescripcion.Text == "" || txtIdCliente.Text == "")
  30.            {
  31.                MessageBox.Show("DEBES INTRODUCIR VALORES...");
  32.            }          
  33.            else
  34.            {
  35.                int NUMERO = Convert.ToInt16(txtNumeroCuenta.Text);
  36.                string DESCRIPCION = txtDescripcion.Text;
  37.                int ID = Convert.ToInt16(txtIdCliente.Text);
  38.                string FECHA = dateTimePicker1.Value.ToString("yyyy-MM-dd");
  39.  
  40.                try
  41.                {
  42.                    IDbConnection dbcon = new NpgsqlConnection("Server = localhost;" + "Database = Facturas;" + "User ID = marcela;");
  43.                    dbcon.Open();
  44.                    IDbCommand dbcmd = dbcon.CreateCommand();
  45.                    dbcmd.CommandText = "insert into Cuentas_extras values(" + NUMERO + ",'" + DESCRIPCION + "'," + ID + ",'" + FECHA + "');";
  46.                    IDataReader reader = dbcmd.ExecuteReader();
  47.                    dbcon.Close();
  48.                    txtNumeroCuenta.Text = "";
  49.                    txtDescripcion.Text = "";
  50.                    txtIdCliente.Text = "";
  51.                    MessageBox.Show("Registro Guardado correctamente");
  52.                }
  53.                catch (Exception msg)
  54.                {
  55.                    MessageBox.Show("error.....\n\n" + msg.ToString());
  56.                }
  57.            }
  58.        }
  59.  
  60.        private void cmdMostrar_Click(object sender, EventArgs e)
  61.        {
  62.            try
  63.            {
  64.                NpgsqlConnection conexion = new NpgsqlConnection("Server = localhost; " + "Database = Facturas;" + "User ID = marcela;");
  65.  
  66.                NpgsqlDataAdapter adaptador = new NpgsqlDataAdapter("select * from Cuentas_extras", conexion);
  67.                DataTable tablamemoria = new DataTable();
  68.                adaptador.Fill(tablamemoria);
  69.                dtaCuentasExtras.DataSource = tablamemoria.DefaultView;
  70.            }
  71.  
  72.            catch (Exception msg)
  73.            {
  74.                MessageBox.Show("Error......\n\n" + msg.ToString());
  75.            }
  76.        }
  77.  
  78.        int n;
  79.        private void cmdBuscar_Click(object sender, EventArgs e)
  80.        {
  81.            if (txtBuscado.Text == "")
  82.            {
  83.                MessageBox.Show("DEBES INTRODUCIR EL NUMERO DE CUENTA A BUSCAR...");
  84.                txtBuscado.Focus();
  85.            }
  86.            else
  87.            {
  88.                try
  89.                {
  90.                    int band = 0;
  91.                    IDbConnection dbcon = new NpgsqlConnection("Server = localhost;" + "Database = Facturas;" + "User ID = marcela;");
  92.                    dbcon.Open();
  93.                    IDbCommand dbcmd = dbcon.CreateCommand();
  94.                    n = Convert.ToInt32(txtBuscado.Text);
  95.                    dbcmd.CommandText = "select * from cuentas_extras where numero_cuenta =" + n + "";
  96.                    IDataReader reader = dbcmd.ExecuteReader();
  97.                    if (reader.Read())
  98.                    {
  99.                        txtDescripcion.Text = reader.GetString(reader.GetOrdinal("descripcion"));
  100.                        txtIdCliente.Text = Convert.ToString(reader.GetInt32(reader.GetOrdinal("id_cliente")));
  101.                        txtNumeroCuenta.Text = Convert.ToString(reader.GetInt32(reader.GetOrdinal("numero_cuenta")));
  102.                        dateTimePicker1.Text = reader.GetString(reader.GetOrdinal("fecha"));
  103.                        band = 1;
  104.                        txtBuscado.Text = "";
  105.                    }
  106.                    dbcon.Close();
  107.                    if (band == 0)
  108.                    {
  109.                        txtBuscado.Text = "";
  110.                        txtDescripcion.Text = "";
  111.                        txtIdCliente.Text = "";
  112.                        txtNumeroCuenta.Text = "";
  113.                        MessageBox.Show("Numero de cuenta no encontrado");
  114.                    }
  115.                }
  116.                catch (Exception msg)
  117.                {
  118.                    MessageBox.Show(msg.ToString());
  119.                }
  120.            }
  121.        }
  122.    }
  123. }
  124.  

gracias
162  Programación / Programación C/C++ / aprender c# en: 14 Mayo 2013, 01:17 am
Saludos

Alguien sabe de algun curso on-line para principiantes de c# o algun libro que sea bueno para aprender este lenguaje

gracias de antemano
163  Foros Generales / Foro Libre / Pastebin en: 7 Mayo 2013, 05:06 am
Alguien sabe porque bloquearon pastebin???? No se si esto es en todos los paises o si es algun asunto de las empresas de internet
164  Programación / Programación C/C++ / invalid input syntax en: 4 Mayo 2013, 18:25 pm
saludos tengo el siguiente codigo en c# pero me sale un error en la linea numero 45 que dice: invalid input syntax for integer...

Código
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Npgsql;
  10.  
  11. namespace Agencia_de_Viajes
  12. {
  13.    public partial class Form5 : Form
  14.    {
  15.        public Form5()
  16.        {
  17.            InitializeComponent();
  18.        }
  19.  
  20.        private void irMenu_Click(object sender, EventArgs e)
  21.        {
  22.            this.Visible = false;
  23.            Form1 menu = new Form1();
  24.            menu.Visible = true;
  25.        }
  26.  
  27.        private void cmdAgregar_Click(object sender, EventArgs e)
  28.        {
  29.            if (txtNumero.Text == "" || txtDescripcion.Text == "" || txtFecha.Text == "" || txtIdCliente.Text == "")
  30.            {
  31.                MessageBox.Show("DEBES INTRODUCIR VALORES...");
  32.            }
  33.            else
  34.            {
  35.                try
  36.                {
  37.                    int NUMERO = Convert.ToInt16(txtNumero.Text);
  38.                    string DESCRIPCION = txtDescripcion.Text;
  39.                    DateTime today = DateTime.Today;
  40.                    string FECHA = today.ToString("yyyy/MM/dd");
  41.                    int ID = Convert.ToInt16(txtIdCliente.Text);
  42.                    IDbConnection dbcon = new NpgsqlConnection("Server = localhost;" + "Database = Facturas;" + "User ID = marcela;");
  43.                    dbcon.Open();
  44.                    IDbCommand dbcmd = dbcon.CreateCommand();
  45.                    dbcmd.CommandText = "insert into Cuentas_extras values(" + NUMERO + ",'" + DESCRIPCION + "','" + FECHA + "'," + ID + ")";
  46.                    IDataReader reader = dbcmd.ExecuteReader();
  47.                    dbcon.Close();
  48.                    txtNumero.Text = "";
  49.                    txtDescripcion.Text = "";
  50.                    txtFecha.Text = "";
  51.                    txtIdCliente.Text = "";
  52.                    MessageBox.Show("Registro Guardado correctamente");
  53.                }
  54.                catch (Exception msg)
  55.                {
  56.                    MessageBox.Show("error.....\n\n" + msg.ToString());
  57.                }
  58.            }
  59.        }
  60.  
  61.        private void cmdMostrar_Click(object sender, EventArgs e)
  62.        {
  63.            try
  64.            {
  65.                NpgsqlConnection conexion = new NpgsqlConnection("Server = localhost; " + "Database = Facturas;" + "User ID = marcela;");
  66.  
  67.                NpgsqlDataAdapter adaptador = new NpgsqlDataAdapter("select * from Cuentas_extras", conexion);
  68.                DataTable tablamemoria = new DataTable();
  69.                adaptador.Fill(tablamemoria);
  70.                dtaCuentasExtras.DataSource = tablamemoria.DefaultView;
  71.            }
  72.  
  73.            catch (Exception msg)
  74.            {
  75.                MessageBox.Show("Error......\n\n" + msg.ToString());
  76.            }
  77.        }
  78.    }
  79. }
  80.  
el problema es cuando le agrego una fecha cualquiera (2013/04/04) es ahi donde me marca el error

de antemano gracias
165  Programación / Bases de Datos / eliminar llave primaria en: 2 Mayo 2013, 18:10 pm
saludos

tengo una entidad en postgres que contiene una llave primaria, al principio intente eliminar toda la entidad con:
 
drop table nombre_tabla;

pero me aparecio un error que decia que primero tenia que eliminar la llave primaria, pero cuando le pongo

alter table nombre_tabla drop primary key; o cuando le pongo esta otra

alter table nombre_tabla drop primary key(nombre de la columna que tiene el primary key);

pero me sale un sintax error y no se por que, alguien sabe de algun comando para solucionar esto??? como le borro la llave primaria a mi tabla???

gracias
166  Programación / Bases de Datos / llaves foraneas y primarias en: 1 Mayo 2013, 21:44 pm
saludos

Tengo una duda conceptual de el manejo de llaves en una base de datos, una entidad puede tener dos llaves foraneas pero ninguna primaria??? es valido esto?

de antemano gracias
167  Informática / Software / Visual Studio en: 22 Abril 2013, 03:48 am
Saludos

Tengo un problema no puedo abrir un proyecto en visual studio y no entiendo por qué, me aparece un mensaje que dice que no se pudo cargar el archivo del proyecto blablabla y otro que dice no se puede encontrar parte de la ruta de acceso

al que me pueda ayudar de antemano gracias
168  Programación / Programación C/C++ / StackOverFlow en: 20 Abril 2013, 03:11 am
Saludos

Estoy haciendo una base de datos que tiene un menu y unas 12 entidades, y les estoy haciendo su interfaz gráfica en c#, estas ventanas tienen que estar enlazadas y la primera vez que lo compile me salió bien los botones del menú me llevaban a la ventana correspodiente y tal. Pero ahora no me compila me aparece un error que dice

No se controló StackOverFlowException

No se puede evaluar la expresión porque el subproceso actual está en un estado de desbordamiento de pila

y me aparece este código también pero no tengo idea de qué significa

Código
  1. //
  2.            // Form3
  3.            //
  4.            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
  5.            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  6.            this.ClientSize = new System.Drawing.Size(388, 347);
  7.            this.Controls.Add(this.cmdIr_Menu);
  8.            this.Controls.Add(this.dataGridView1);
  9.            this.Controls.Add(this.cmdMostrar);
  10.            this.Controls.Add(this.cmdAgregar);
  11.            this.Controls.Add(this.txtServicios);
  12.            this.Controls.Add(this.txtCategoria);
  13.            this.Controls.Add(this.txtTipo);
  14.            this.Controls.Add(this.txtTel);
  15.            this.Controls.Add(this.txtUbicacion);
  16.            this.Controls.Add(this.txtIdHotel);
  17.            this.Controls.Add(this.txtNombre);
  18.            this.Controls.Add(this.servicios);
  19.            this.Controls.Add(this.categoria);
  20.            this.Controls.Add(this.tipo);
  21.            this.Controls.Add(this.txtTelefono);
  22.            this.Controls.Add(this.ubicacion);
  23.            this.Controls.Add(this.idHotel);
  24.            this.Controls.Add(this.nombre);
  25.            this.Controls.Add(this.alojamiento);
  26.            this.Name = "Form3";
  27.            this.Text = "Form3";
  28.            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
  29.            this.ResumeLayout(false);//Aqui esta el error
  30.            this.PerformLayout();
  31.  
  32.        }

 el error supuestamente esta en las ultimas lineas, la verdad estoy medio desesperada porque segun yo no habia nada mal

si alguien me pudiera ayudar le agradeceria mucho
169  Programación / Bases de Datos / alter column en: 16 Abril 2013, 19:30 pm

Tengo una tabla llamada clientes hecha en postgres que tiene dos campos (columnas),una nombre como varchar y la otra id como char, el problema es que cometí un error y el campo id debería ser de tipo int, pero a la hora de tratar modificarlo con:

alter table clientes alter column id type int;

me marca un error que dice:

la columna id no puede convertirse al tipo <pg_catalog.int4> y no sé por qué me da ese error

de antemano gracias
170  Programación / .NET (C#, VB.NET, ASP) / mensaje de error c# en: 14 Abril 2013, 21:28 pm
Saludos

estoy haciendo el siguiente código  en c# pero me marca dos errores en varias lineas del código que dicen

El nombre txtId no existe en el conexto actual
El nombre txtNombre no existe en el contexto actual

no entiendo por qué me da esos errores, esta es la primera vez que programo en c#

Código
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Npgsql;
  10. using Mono.Security;
  11.  
  12. namespace Proyecto_BasesDatos
  13. {
  14.    public partial class Form1 : Form
  15.    {
  16.        public Form1()
  17.        {
  18.            InitializeComponent();
  19.        }
  20.  
  21.        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
  22.        {
  23.  
  24.        }
  25.  
  26.        private void cmdAgregar_Click(object sender, EventArgs e)
  27.        {
  28.            if (txtId.Text == "" || txtNombre.Text == "")
  29.            {
  30.                MessageBox.Show("Debes Introducir Valores");
  31.            }
  32.            else
  33.            {
  34.                try
  35.                {
  36.                    string Nombre = txtNombre.Text;
  37.                    int Id = Convert.ToInt16(txtId.Text);
  38.                    IDbConnection dbcon = new NpgsqlConnection("Server=localhost;" + "Database=Conexion;" + "User Id=Marcela;");
  39.                    dbcon.Open();
  40.                    IDbCommand dbcmd = dbcon.CreateCommand();
  41.                    dbcmd.CommandText = "insert into Clientes values (" + Id + " , '" + Nombre + "')";
  42.                    IDataReader reader = dbcmd.ExecuteReader();
  43.                    dbcon.Close();
  44.                    txtNombre.Text = "";
  45.                    txtId.Text = "";
  46.                    MessageBox.Show("Registro Guardado Correctamente");
  47.                }
  48.                catch (Exception msg)
  49.                {
  50.                    MessageBox.Show("error.......................\n\n" + msg.ToString());
  51.                }
  52.  
  53.            }
  54.  
  55.        }
  56.  
  57.  
  58.    }
  59. }

gracias
Páginas: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [17] 18 19 20 21 22
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines