Article View: borland.public.cppbuilder.database.ado
Article #5041Re: Connection dead
From: Harold Howe (TeamB)
Date: Sun, 05 Aug 2001 21:48
Date: Sun, 05 Aug 2001 21:48
37 lines
1933 bytes
1933 bytes
Henrik Franz๏ฟฝn wrote:
>
> I have a problem with an ADO connection. I connect to a database. I can get
> all tables, but after a this i get a error. It seems like the
> connectionobject is dead (NIL)..
I have an app that I want to keep connected to the database at all times. Its a
server type of app. After a while, SQLServer just seems to drop the connection on me.
To combat this, I use code like this. Maybe you can try something similar.
ADOdataset->Parameters->ParamByName("foo")->Value = "bar";
try
{
ADOdataset->Open();
}
catch (EOleError &e)
{
// if an OLE error occurs, then perhaps we have lost our ADO connection,
// toggle the connection object and retry
try
{
ADOdataset->Connection->Connected = false;
ADOdataset->Connection->Connected = true;
ADOdataset->Open();
}
catch (Exception &e)
{
// nothing we can do really, just rethrow and maybe log an
// error message
throw;
}
}
You can bundle this all into a function to keep your code clean.
Harold Howe [TeamB]
http://www.bcbdev.com
Technical Details
Message-ID:
<3B6DBF1D.82FB6F3@bcbdev.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!195.238.2.15!skynet.be!newsfeed1.uni2.dk!newssuck.uni2.dk!dnewsReferences:
<3b5fdf14_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10698b,6744f1abb7486ef6 X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2001-08-05 15:01:58 PST Message-ID: <3B6DBF1D.82FB6F3@bcbdev.com> Date: Sun, 05 Aug 2001 16:48:13 -0500 From: "Harold Howe (TeamB)" <hhowe@bcbdev.com> X-Mailer: Mozilla 4.03 [en] (WinNT; I) MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.database.ado Subject: Re: Connection dead References: <3b5fdf14_1@dnews> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit NNTP-Posting-Host: 24.22.227.236 X-Trace: dnews 997048082 24.22.227.236 (5 Aug 2001 14:48:02 -0700) Lines: 37 Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!195.238.2.15!skynet.be!newsfeed1.uni2.dk!newssuck.uni2.dk!dnews