RE: valores nulos

From: Ramón Alberto Bruening González <albertobruening(at)hotmail(dot)com>
To: <desarrollo(dot)escuintla(at)gmail(dot)com>, <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: RE: valores nulos
Date: 2010-02-21 19:02:52
Message-ID: SNT137-w611FFF2E13FDB84F205FA0A2440@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda


Seria interesante ver el procedimiento desde donde llamas a guardardatos.

podria ser que le estes pasando el TextBox y no el TextBox.Text que son cosas distintas en .NET.

El TextBox siempre tiene algun valor y el TextBox.Text en si puede estar vacio.

Date: Sat, 20 Feb 2010 14:53:17 -0600
Subject: [pgsql-es-ayuda] valores nulos
From: desarrollo(dot)escuintla(at)gmail(dot)com
To: pgsql-es-ayuda(at)postgresql(dot)org

Hola lista,

tengo la siguiente tabla en PostgreSQL 8.4.2;

CREATE TABLE depto
(
codigo text NOT NULL,
zona text NOT NULL,
descripcion character varying(30) NOT NULL,
tipo character varying(15) NOT NULL,

CONSTRAINT "depto_pkey" PRIMARY KEY (codigo)
)

y el siguiente codigo en C#, para guardar un registro:

public void guardaDatos(String strCodigo, String strZona,String strDesc,String strTipo){

String strInsertSql="INSERT INTO depto VALUES (@Codigo,@Zona,@Desc,@Tipo)";
NpAdapter.InsertCommand=new NpgsqlCommand(strInsertSql,Cnn.getConexion());
NpParam=NpAdapter.InsertCommand.Parameters.Add("@User",NpgsqlTypes.NpgsqlDbType.Text);

NpParam.SourceColumn="codigo";
NpParam.SourceVersion=DataRowVersion.Current;
NpParam=NpAdapter.InsertCommand.Parameters.Add("@Clave",NpgsqlTypes.NpgsqlDbType.Text);

NpParam.SourceColumn="zona";
NpParam.SourceVersion=DataRowVersion.Current;
NpParam=NpAdapter.InsertCommand.Parameters.Add("@Desc",NpgsqlTypes.NpgsqlDbType.Text);

NpParam.SourceColumn="descripcion";
NpParam.SourceVersion=DataRowVersion.Current;
NpParam=NpAdapter.InsertCommand.Parameters.Add("@Tipo",NpgsqlTypes.NpgsqlDbType.Text);

NpParam.SourceColumn="tipo";
NpParam.SourceVersion=DataRowVersion.Current;
DataTable tabla=dset.Tables[0];
DataRow dr=tabla.NewRow();
dr["codigo"]=strCodigo;

dr["zona"]=strZona;
dr["descripcion"]=strDesc;
dr["tipo"]=strTipo;
tabla.Rows.Add(dr);
UpdateObj();
}

Pero resulta que estoy haciendo pruebas de INSERCIÓN, y me acepta registros
con valores nulos,

Es decir, los parametros que le envio a la funcion "guardaDatos", son los Text de varios TextBox correspondientes,

y probando con Text vacios, esto se guardan.

Pero según la declaración de la tabla, los campos estan declarados como NOT NULL,

--
Saludos

_________________
José de Paz

Escuintla, Guatemala
Tel. (502)-56041676

http://desarrolloescuintla.wordpress.com


_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Marcelo Sosa 2010-02-22 12:13:50 Ayuda con backup no funcione restore Urgente!!!
Previous Message Pablo Braulio 2010-02-21 18:52:49 Campo de imagenes en migración de access a postgresql.