ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,563 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi All,
I use DataReader as below, why the 1st row is skipped?, what I have missed?
using (NpgsqlConnection conn = new NpgsqlConnection(Models.AppSettings.PG_SQL.Connection_String))
{
try
{
string sql = "select c.pid, c.iccid, c.network, c.cdatetime, c.start_datetime, c.network_id from cdrs c " +
"where TO_CHAR(c.start_datetime, 'YYYY-MM-DD') >= '2024-04-01' " +
"and " +
"TO_CHAR(c.start_datetime, 'YYYY-MM-DD') <= '2024-04-12' and iccid='" + __iccid + "' " +
"order by c.iccid, c.cdatetime";
using (var dr = conn.ExecuteReader(sql, new
{
}))
{
while (dr.Read())
{
long pid = dr.GetInt64(dr.GetOrdinal("pid"));
// the 1st pid was skipped here!, I double checked
}
}
}
catch (Exception e) { Helper.SaveLogAsync("CDR.test: " + e.ToString(), Models.Errs.ErrType.Err); }
finally { }
}