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.escuin...@gmail.com
To: pgsql-es-ayuda@postgresql.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

Responder a