long sMoId = 0;这个是全局变量 SqlDataAdapter _damo =new SqlDataAdapter("spCP_Read_mo", db);
_damo.SelectCommand.CommandType=CommandType.StoredProcedure;
_damo.SelectCommand.Parameters.Add("@MoId",SqlDbType.BigInt);
_damo.SelectCommand.Parameters["@MoId"].Value=sMoId;//(这个值是可变的)
_damo.Fill(ds, "_tbmo"); int iMo=ds.Tables["_tbmo"].Rows.Count;
if(iMo!=0)
{
sMoId=long.Parse(ds.Tables["_tbmo"].Rows[iMo-1]["id"].ToString());//查出最大的ID值
string sTempId="";
for(int iFlag=0;iFlag<iMo;iFlag++)
{
sTempId=sTempId+","+ds.Tables["_tbmo"].Rows[iFlag]["id"].ToString();
} sTemp="当前队列数据[MO="+iMo.ToString()+"明细="+sTempId+"]";
存储过程spCp_read_moALTER proc spCP_Read_Mo
@MoId bigint
as--spCP_Read_Mo 0if @MoId=0
select top 50 * from cp_sp_syn_mo with(nolock) order by Id
else
select top 50 * from cp_sp_syn_mo with(nolock) where id>@MoId order by Id
现在偶尔会出现sTemp返回数据:当前队列数据[MO=5明细=,15519328,15519329,15519330,15519331,15519335]缺少15519332-334这几个id值对应的记录,实际cp_sp_syn_mo里有这些数据记录的。
本代码外围有lock(this.ds)的,这会是什么原因导致的呢?
_damo.SelectCommand.CommandType=CommandType.StoredProcedure;
_damo.SelectCommand.Parameters.Add("@MoId",SqlDbType.BigInt);
_damo.SelectCommand.Parameters["@MoId"].Value=sMoId;//(这个值是可变的)
_damo.Fill(ds, "_tbmo"); int iMo=ds.Tables["_tbmo"].Rows.Count;
if(iMo!=0)
{
sMoId=long.Parse(ds.Tables["_tbmo"].Rows[iMo-1]["id"].ToString());//查出最大的ID值
string sTempId="";
for(int iFlag=0;iFlag<iMo;iFlag++)
{
sTempId=sTempId+","+ds.Tables["_tbmo"].Rows[iFlag]["id"].ToString();
} sTemp="当前队列数据[MO="+iMo.ToString()+"明细="+sTempId+"]";
存储过程spCp_read_moALTER proc spCP_Read_Mo
@MoId bigint
as--spCP_Read_Mo 0if @MoId=0
select top 50 * from cp_sp_syn_mo with(nolock) order by Id
else
select top 50 * from cp_sp_syn_mo with(nolock) where id>@MoId order by Id
现在偶尔会出现sTemp返回数据:当前队列数据[MO=5明细=,15519328,15519329,15519330,15519331,15519335]缺少15519332-334这几个id值对应的记录,实际cp_sp_syn_mo里有这些数据记录的。
本代码外围有lock(this.ds)的,这会是什么原因导致的呢?
存储过程spCp_read_mo ALTER proc spCP_Read_Mo
@MoId bigint
as --spCP_Read_Mo 0
select top 50 * from cp_sp_syn_mo with(nolock) where id>@MoId order by Id
因为ID不会小于0
2009-11-12 15:10:48.359|Mo-Syn获取数据出错,意外跳编号!15843349-15843331?18
数据库中的实际数据id及写入时间情况15843349 2009-11-12 15:10:48.200
15843348 2009-11-12 15:10:48.200
15843347 2009-11-12 15:10:48.200
15843346 2009-11-12 15:10:48.200
15843345 2009-11-12 15:10:48.200
15843344 2009-11-12 15:10:48.187
15843343 2009-11-12 15:10:48.187
15843342 2009-11-12 15:10:48.187
15843341 2009-11-12 15:10:47.983
15843340 2009-11-12 15:10:47.983
15843339 2009-11-12 15:10:47.967
15843338 2009-11-12 15:10:47.967
15843337 2009-11-12 15:10:47.967
15843336 2009-11-12 15:10:47.967
15843335 2009-11-12 15:10:47.967
15843334 2009-11-12 15:10:47.950
15843333 2009-11-12 15:10:47.950
15843332 2009-11-12 15:10:47.950
15843331 2009-11-12 15:10:47.950