invalid input syntax

Iniciado por m@o_614, 4 Mayo 2013, 18:25 PM

0 Miembros y 1 Visitante están viendo este tema.

m@o_614

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 (csharp) [Seleccionar]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Npgsql;

namespace Agencia_de_Viajes
{
    public partial class Form5 : Form
    {
        public Form5()
        {
            InitializeComponent();
        }

        private void irMenu_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            Form1 menu = new Form1();
            menu.Visible = true;
        }

        private void cmdAgregar_Click(object sender, EventArgs e)
        {
            if (txtNumero.Text == "" || txtDescripcion.Text == "" || txtFecha.Text == "" || txtIdCliente.Text == "")
            {
                MessageBox.Show("DEBES INTRODUCIR VALORES...");
            }
            else
            {
                try
                {
                    int NUMERO = Convert.ToInt16(txtNumero.Text);
                    string DESCRIPCION = txtDescripcion.Text;
                    DateTime today = DateTime.Today;
                    string FECHA = today.ToString("yyyy/MM/dd");
                    int ID = Convert.ToInt16(txtIdCliente.Text);
                    IDbConnection dbcon = new NpgsqlConnection("Server = localhost;" + "Database = Facturas;" + "User ID = marcela;");
                    dbcon.Open();
                    IDbCommand dbcmd = dbcon.CreateCommand();
                    dbcmd.CommandText = "insert into Cuentas_extras values(" + NUMERO + ",'" + DESCRIPCION + "','" + FECHA + "'," + ID + ")";
                    IDataReader reader = dbcmd.ExecuteReader();
                    dbcon.Close();
                    txtNumero.Text = "";
                    txtDescripcion.Text = "";
                    txtFecha.Text = "";
                    txtIdCliente.Text = "";
                    MessageBox.Show("Registro Guardado correctamente");
                }
                catch (Exception msg)
                {
                    MessageBox.Show("error.....\n\n" + msg.ToString());
                }
            }
        }

        private void cmdMostrar_Click(object sender, EventArgs e)
        {
            try
            {
                NpgsqlConnection conexion = new NpgsqlConnection("Server = localhost; " + "Database = Facturas;" + "User ID = marcela;");

                NpgsqlDataAdapter adaptador = new NpgsqlDataAdapter("select * from Cuentas_extras", conexion);
                DataTable tablamemoria = new DataTable();
                adaptador.Fill(tablamemoria);
                dtaCuentasExtras.DataSource = tablamemoria.DefaultView;
            }

            catch (Exception msg)
            {
                MessageBox.Show("Error......\n\n" + msg.ToString());
            }
        }
    }
}
el problema es cuando le agrego una fecha cualquiera (2013/04/04) es ahi donde me marca el error

de antemano gracias