I need its collaboration so that they say as to fill a DataSet to me from a PgSqlDataReader in automatica form.

I need its collaboration so that they say as to fill a DataSet to me from a PgSqlDataReader in automatica form.

Postby felmarla » Mon 28 Nov 2005 20:33

all I manipulate from the class connection, leave errors when filling datagrid or dropdownlist.
error
find cannot colunm or error syntaxis near select

the problem I have it in the handling of the cursors when I execute functions, datagrid full good the first time that I call this metodo but when doing to insert does not return to fill.error syntaxis near select.

I need its collaboration so that they say as to fill a DataSet to me from a PgSqlDataReader in automatica form.


public int seleccionar(string procedimiento, DataSet salida, string nombreTabla, params Parametro[] parametros)
{
string cadena;
pgconec.Open();
try
{
otra=pgconec.BeginTransaction();
try
{
salida.Tables[nombreTabla].Rows.Clear();
pgcoman.Parameters.Clear();
cadena = "select * from " +procedimiento+"(";
// Se adicionan los parametros al comando

for (int i =0 ; i < parametros.Length; i++)
{
Parametro p = parametros[i];
cadena += "'"+ p.Valor +"',";

}
cadena+="'ref'"+")";
pgcoman.CommandText=cadena;
pgdr=pgcoman.ExecuteReader();
pgcoman.CommandText=("fetch all in \"ref\"");
pgdr=pgcoman.ExecuteReader();
while(pgdr.Read())
{
DataRow fila = salida.Tables[nombreTabla].NewRow();
for(int k=0;k{
fila[k] = pgdr.GetValue(k);
}
salida.Tables[nombreTabla].Rows.Add(fila);
}

otra.Commit();
return 0; //no hubo error

}
catch (SqlException serr)
{
//this.pgconec.Close();
otra.Rollback();
this.error = serr.Message.ToString();
return serr.Number; //retorna el número de error postgres sql
}
catch (Exception ex)
{
//this.pgconec.Close();
otra.Rollback();
this.error = ex.Message.ToString();
return -1; //retorna el número de error del sistema
}
}
finally
{
pgconec.Close();
}

}
felmarla
 
Posts: 5
Joined: Thu 24 Nov 2005 14:16

Return to dotConnect for PostgreSQL