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

 

 


Tema destacado: Trabajando con las ramas de git (tercera parte)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  invalid input syntax
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: invalid input syntax  (Leído 1,475 veces)
m@o_614


Desconectado Desconectado

Mensajes: 389


Ver Perfil
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


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Regular Expressions Syntax
Scripting
magarcan 0 1,925 Último mensaje 14 Noviembre 2007, 16:16 pm
por magarcan
[Ayuda] SQL syntax error
PHP
K4sS- 1 1,809 Último mensaje 26 Agosto 2012, 00:47 am
por alexander1712
[C++][Qt en C::B]Aporte syntax highlighting
Programación C/C++
anonimo12121 2 2,692 Último mensaje 30 Octubre 2012, 21:39 pm
por anonimo12121
[PYTHON] Error: invalid syntax
Scripting
jalbtercero 2 3,196 Último mensaje 31 Enero 2015, 20:15 pm
por tincopasan
[Ayuda] Python - SyntaxError: invalid syntax
Programación General
W17CH3R 6 4,560 Último mensaje 2 Agosto 2021, 18:52 pm
por W17CH3R
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines