关于odbc超时的处理

yanyanyan165 2018-09-03 12:57:16
我这里链接无线网络,经常断开,环境没法改变。程序要向一个远程数据库实时写数据,超时不成功就补传。现在超时,系统抛对话框,怎样才能不由系统抛对话框,本程序处理超时异常呢?
odbc链接Oracle11g,操作用的mfc的cRecordset 。
...全文
483 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2018-09-03
  • 打赏
  • 举报
回复
CDatabase::SetLoginTimeout
void SetLoginTimeout( DWORD dwSeconds );

Parameters

dwSeconds

The number of seconds to allow before a connection attempt times out.

Remarks

Call this member function — before you call OpenEx or Open — to override the default number of seconds allowed before an attempted data source connection times out. A connection attempt might time out if, for example, the DBMS is not available. Call SetLoginTimeout after you construct the uninitialized CDatabase object but before you call OpenEx or Open.

The default value for login timeouts is 15 seconds. Not all data sources support the ability to specify a login timeout value. If the data source does not support timeout, you get trace output but not an exception. A value of 0 means “infinite.”

CDatabase Overview | Class Members | Hierarchy Chart

See Also CDatabase::OnSetOptions, CDatabase::SetQueryTimeout


CDatabase::SetQueryTimeout
void SetQueryTimeout( DWORD dwSeconds );

Parameters

dwSeconds

The number of seconds to allow before a query attempt times out.

Remarks

Call this member function to override the default number of seconds to allow before subsequent operations on the connected data source time out. An operation might time out due to network access problems, excessive query processing time, and so on. Call SetQueryTimeout prior to opening your recordset or prior to calling the recordset’s AddNew, Update or Delete member functions if you want to change the query timeout value. The setting affects all subsequent Open, AddNew, Update, and Delete calls to any recordsets associated with this CDatabase object. Changing the query timeout value for a recordset after opening does not change the value for the recordset. For example, subsequent Move operations do not use the new value.

The default value for query timeouts is 15 seconds. Not all data sources support the ability to set a query timeout value. If you set a query timeout value of 0, no timeout occurs; the communication with the data source may hang. This behavior may be useful during development. If the data source does not support timeout, you get trace output but not an exception.

CDatabase Overview | Class Members | Hierarchy Chart

See Also CDatabase::SetLoginTimeout
zgl7903 2018-09-03
  • 打赏
  • 举报
回复
捕获 CDBException 自己处理?
try
{
……
}
catch(CDBException *e)
{
####
e->Delete();
}
sevancheng 2018-09-03
  • 打赏
  • 举报
回复
写入失败的保存在队列,由另外1个线程去写

4,018

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧