Help PgSqlDataAdapter and Cursores.

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
felmarla
Posts: 5
Joined: Thu 24 Nov 2005 14:16

Help PgSqlDataAdapter and Cursores.

Post by felmarla » Tue 06 Dec 2005 22:54

I am working cursors, and I need to fill dataset with a PgSqlDataAdapter.Pero presents/displays an error to me of violation of fields not null, since when executing the procedure this returns in the reference to the cursor in position zero of tabla.La I eliminate but it is that pasa..No funciona.El I cosay to me is the following one.

public int seleccionar(string procedimiento, DataSet salida, string nombreTabla, params Parametro[] parametros)
{

try
{
pgconec.Open();
otra=pgconec.BeginTransaction();
try
{
pgcoman.Parameters.Clear();
pgcoman.CommandType=CommandType.StoredProcedure;
pgcoman.CommandText=procedimiento;

// Se adicionan los parametros al comando
foreach (Parametro param in parametros)
pgcoman.Parameters.Add(param.Nombre,param.Valor);

//se adiciona la referencia al cursor a el comando
pgcoman.Parameters.Add(new CoreLab.PostgreSql.PgSqlParameter("p1", CoreLab.PostgreSql.PgSqlType.VarChar,3, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, "ref"));
pgda.SelectCommand=(pgcoman);
pgda.Fill(salida.Tables[nombreTabla]);//se llena el dataset con la consulta

pgcoman.CommandType=CommandType.Text;
pgcoman.Parameters.Clear();
pgcoman.CommandText="fetch all in \"ref\"";
pgda.SelectCommand=(pgcoman);
pgda.Fill(salida.Tables[nombreTabla]);
salida.Tables[nombreTabla].Rows[0].Delete();
salida.Tables[nombreTabla].AcceptChanges();
otra.Commit();
return 0;//no hubo error
}
catch (SqlException serr)
{
otra.Rollback();
this.error = serr.Message.ToString();
return serr.Number; //retorna el número de error postgres sql
}
catch (Exception ex)
{
otra.Rollback();
this.error = ex.Message.ToString();
return -1; //retorna el número de error del sistema
}
}
finally
{

pgconec.Close();
}

}

SecureGen
Devart Team
Posts: 133
Joined: Thu 08 Sep 2005 06:27

Post by SecureGen » Thu 08 Dec 2005 14:34

Unfortunatly I did not have enough information to test your example. Please let me know the following things:
- In which line of code you recieve an error;
- What is the full text of error message and current call stack;

It would be great if you create small independent example that reproduces your problem and send me an e-mail with the source code and DDL script. In such case I can reproduce your problem on my environment.

Post Reply