Foro de elhacker.net

Programación => Programación C/C++ => Mensaje iniciado por: m@o_614 en 4 Mayo 2013, 18:25 pm



Título: invalid input syntax
Publicado por: m@o_614 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