Code: Select all
System.NullReferenceException: Object reference not set to an instance of an object.
at Devart.Data.PostgreSql.PgSqlDataReader.a(q[] A_0)
at Devart.Data.PostgreSql.PgSqlDataReader.e(Int32 A_0)
at Devart.Data.PostgreSql.PgSqlCommand.InternalExecute(CommandBehavior behavior, IDisposable stmt, Int32 startRecord, Int32 maxRecords)
at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
at Vetstreet.Hd.Data.Command.ExecuteReader()
at Vetstreet.Hd.Core.Data.LocationInfoData.GetLocationInfo(Int32 locationId)
Also note that another database call successfully happens just prior to this call, though it is an ExecuteNonQuery. I know this is successful because the output parameters are used by the method mentioned in the error.
We have 4 environments, but we are experiencing this error only on our production environment.
Appreciate your help in troubleshooting this error. We suspect a configuration difference in production, but any suggestions on what to check are appreciated.
we are using:
Devart.Data: 5.0.1.0
Devart.Data.PostgreSql: 4.0.12.0
PostgreSQL 8.3
The C# method calling the db function
Code: Select all
public static LocationInfo GetLocationInfo(int locationId)
{
LocationInfo info = new LocationInfo();
IDataReader dr = null;
IDbTransaction tn = null;
using (Connection cn =new Connection())
using (Command cmd = new Command("hd.get_hdlocs", cn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("in_hdloc_id", locationId);
try
{
cn.Open();
tn = cn.BeginTransaction();
dr = cmd.ExecuteReader();
if (dr.Read())
{
info.Address1 = Helpers.GetString(dr["address1"]);
//. . .Other Object Assignments . . .//
}
dr.Close();
}
catch (Exception ex)
{
log.Error("Error in GetLocationInfo calling stored procedure hd.get_hdlocs for location id " + locationId.ToString(), ex);
}
finally
{
if (tn != null)
tn.Commit(); // only a get proc, so just commit
if (cn.State != ConnectionState.Closed)
cn.Close();
}
}
return info;
}
Code: Select all
CREATE OR REPLACE FUNCTION hd.get_hdlocs(in_hdloc_id integer)
RETURNS SETOF refcursor AS
$BODY$
declare
v_ref1 refcursor;
begin
open v_ref1 for
[select statement]
return next v_ref1;
exception
when others then
raise notice 'hd.get_hdlocs failed - % (%)',SQLERRM,SQLSTATE;
return;
end;
$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100
ROWS 1000;
ALTER FUNCTION hd.get_hdlocs(integer) OWNER TO ----;
Jeff