怎样做才能知道程序连接的数据库服务器重起了,并重新建立数据库的连接重新打开表(用odbc)? 各位高手请指点一二! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 odbc 能报错的吧.....看一下ODBC ,SDK上能有 1.不要让应用程序这时在有读写数据库操作时发生异常使程序飞掉使用try,catch(...)2.响应ADO的通知事件(可以参考文档中心里ADO数据库编程入门 ) catch(_com_error &e) { // Notify the user of errors if any. _variant_t vtConnect = pRstAuthors1->GetActiveConnection(); // GetActiveConnection returns connect string if connection // is not open, else returns Connection object. switch(vtConnect.vt) { case VT_BSTR://这个错误能显示你要的信息 erfile=OrderID; erfile=erfile+" ErrorRetCall!Message ="; erfile=erfile+e.ErrorMessage(); erfile=erfile+" Source = "; erfile=erfile+e.Source(); erfile=erfile+" Description ="; erfile=erfile+e.Description(); erfile=erfile+"\n"; if (pRstAuthors1) if (pRstAuthors1->State == adStateOpen) pRstAuthors1->Close(); return 1; case VT_DISPATCH: PrintProviderError(OrderID,vtConnect); if (pRstAuthors1) if (pRstAuthors1->State == adStateOpen) pRstAuthors1->Close(); return 1; //break; default: erfile=OrderID+" Errors occured for RetCall().\n"; if (pRstAuthors1) if (pRstAuthors1->State == adStateOpen) pRstAuthors1->Close(); return 1; //break; } } if (pRstAuthors1) if (pRstAuthors1->State == adStateOpen) pRstAuthors1->Close(); return 0;} CDatabase db ;// 不要使用try 和catchTRY{ db.open( ... ) ;}CATCH (CDBException e){}END CATCH判断是否连接着if (db.IsOpen ()){} CATCH ( CDBException , e)上边写错了我这机器上没有msdn,只能凭记忆写了 把光标放在CATCH上,按F12,察看它的定义,可以发现这些定义的意思及相关的定义 ioctlsocket()win7下 出现10045错误 XP下正常 ? 请问我这个opengl错误是什么原因 CTreeCtrl在指定位置插入节点? 求助:socket编程中,connect 10060错误 请问哪一类钩子能过钩到窗口创建的消息,并且能够修改窗体尺寸??? 那位兄弟做过图象匹配软件 请问哪里有关于COM的教学的书下载,谢谢! 如何把一个程序做成试用版 关于一个线程关闭,重启的问题 我提的问题怎么没了 函数的返回值可以是CString的对象吗? 为什么调用这样的DLL会出现非常操作?
看一下ODBC ,SDK上能有
使用try,catch(...)
2.响应ADO的通知事件(可以参考文档中心里ADO数据库编程入门 )
{
// Notify the user of errors if any.
_variant_t vtConnect = pRstAuthors1->GetActiveConnection(); // GetActiveConnection returns connect string if connection
// is not open, else returns Connection object.
switch(vtConnect.vt)
{
case VT_BSTR://这个错误能显示你要的信息
erfile=OrderID;
erfile=erfile+" ErrorRetCall!Message =";
erfile=erfile+e.ErrorMessage();
erfile=erfile+" Source = ";
erfile=erfile+e.Source();
erfile=erfile+" Description =";
erfile=erfile+e.Description();
erfile=erfile+"\n";
if (pRstAuthors1)
if (pRstAuthors1->State == adStateOpen)
pRstAuthors1->Close();
return 1;
case VT_DISPATCH:
PrintProviderError(OrderID,vtConnect);
if (pRstAuthors1)
if (pRstAuthors1->State == adStateOpen)
pRstAuthors1->Close();
return 1;
//break;
default:
erfile=OrderID+" Errors occured for RetCall().\n";
if (pRstAuthors1)
if (pRstAuthors1->State == adStateOpen)
pRstAuthors1->Close();
return 1;
//break;
}
}
if (pRstAuthors1)
if (pRstAuthors1->State == adStateOpen)
pRstAuthors1->Close(); return 0;
}
// 不要使用try 和catch
TRY
{
db.open( ... ) ;
}
CATCH (CDBException e)
{
}
END CATCH判断是否连接着
if (db.IsOpen ())
{
}
上边写错了
我这机器上没有msdn,只能凭记忆写了