一方面一个服务器程序以ADO连接的方式定时将数据存入SQL数据库,另一面一程序采用ODBC定时访问数据库,从中读取数据以在地图上实时显示,当读取到一定数据之后,发现信息停止更新了,而数据库信息是在更新的。奇怪的是采用记录回放的形式,从数据库读取数据显示的时候就不会出现这种问题(也就是说单独访问数据库就不出错),请高手指教。下面是代码:
//下面两行是设定读取数据的时间间隔,初始化开始跟踪标志
SetTimer(100,1500,NULL);
m_bIsStartGps=TRUE;
........................下面是实现读取的代码:
int i,j;
char str3[17],str4[16];
if(!m_pSet->IsEOF())
{//下面是判断时间信息是否符合,是就读取 ,否则进入下一条记录
if(strcmp(m_pSet->m_RevDate.GetBuffer(m_pSet->m_RevDate.GetLength()),t)==0)
{
str1=m_pSet->m_Longi.GetBuffer(m_pSet->m_Longi.GetLength());
str2=m_pSet->m_Lati.GetBuffer(m_pSet->m_Lati.GetLength());
for(i=1,j=0;*(str1+i)!='\0';i++,j++)//对地理信息进行类型转换,从CString到float类型,并去掉第一字节
{
str3[j]=*(str1+i);
str4[j]=*(str2+i);
}
str3[j]='\0';
theApp.mapCenterX=atof(str3);
theApp.mapCenterY=atof(str4);
theApp.date=m_pSet->m_RevDate;//这几行是为了后面再对话框中显示当前的相关信息做的工作
theApp.longi=m_pSet->m_Longi;
theApp.lati=m_pSet->m_Lati;
theApp.time=m_pSet->m_RevTime;
theApp.high=m_pSet->m_High;
theApp.labdata=m_pSet->m_TagData;
theApp.carnum=m_pSet->m_CarNum;
theApp.speed=m_pSet->m_Speed;
m_pSet->MoveNext();
}
else
m_pSet->MoveNext();
}
else if(flag==0)//这里用来判断数据库是否断开了
{
OnEndGps();
AfxMessageBox("数据库连接断开,跟踪结束!");
}
else
m_pSet->MovePrev();//如果当前行没有数据,就移动到上一条
gpsTargetArray.Run();
UpdateSense();
//下面两行是设定读取数据的时间间隔,初始化开始跟踪标志
SetTimer(100,1500,NULL);
m_bIsStartGps=TRUE;
........................下面是实现读取的代码:
int i,j;
char str3[17],str4[16];
if(!m_pSet->IsEOF())
{//下面是判断时间信息是否符合,是就读取 ,否则进入下一条记录
if(strcmp(m_pSet->m_RevDate.GetBuffer(m_pSet->m_RevDate.GetLength()),t)==0)
{
str1=m_pSet->m_Longi.GetBuffer(m_pSet->m_Longi.GetLength());
str2=m_pSet->m_Lati.GetBuffer(m_pSet->m_Lati.GetLength());
for(i=1,j=0;*(str1+i)!='\0';i++,j++)//对地理信息进行类型转换,从CString到float类型,并去掉第一字节
{
str3[j]=*(str1+i);
str4[j]=*(str2+i);
}
str3[j]='\0';
theApp.mapCenterX=atof(str3);
theApp.mapCenterY=atof(str4);
theApp.date=m_pSet->m_RevDate;//这几行是为了后面再对话框中显示当前的相关信息做的工作
theApp.longi=m_pSet->m_Longi;
theApp.lati=m_pSet->m_Lati;
theApp.time=m_pSet->m_RevTime;
theApp.high=m_pSet->m_High;
theApp.labdata=m_pSet->m_TagData;
theApp.carnum=m_pSet->m_CarNum;
theApp.speed=m_pSet->m_Speed;
m_pSet->MoveNext();
}
else
m_pSet->MoveNext();
}
else if(flag==0)//这里用来判断数据库是否断开了
{
OnEndGps();
AfxMessageBox("数据库连接断开,跟踪结束!");
}
else
m_pSet->MovePrev();//如果当前行没有数据,就移动到上一条
gpsTargetArray.Run();
UpdateSense();
再说,干嘛不用异常依据来搞再说,干嘛不直接用SQL语句
就算是ACCESS也会有这样的情况之所以让你用SQL语句,是SQL语句速度对象较快
现象有点像你这样,断流一样
我建议是搞下迷你MSSQL,看看用他有没有什么影响!
才尽了