🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #1414

Re: proper form for a try/catch on an ado object

#1414
From: Viatcheslav V. Vassiliev
Date: Thu, 15 Jul 2004 11:29
62 lines
3032 bytes
Some operations does require Open()/Close(), other - no. It is easy to test.
If you will call Open()/Close() - you may have less problems while debugging
of searching bugs.

//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)

"steve" <sportock@hotmail.com> �������/�������� � �������� ���������:
news:40f640b5$1@newsgroups.borland.com...
>
> "Viatcheslav V. Vassiliev" <support@oledbdirect.com> wrote:
> >As usual:
> >
> >TADODataSet *rs = new TADODataSet(NULL);
> >try
> >{
> >  rs->Connection = frmFrame->adoConnection;
> >  //This may be set in designer or on connection-related code.
> >  rs->Connection->LoginPrompt = false;
> >  rs->CommandText = sql;
> >  rs->Open();
> >  try
> >  {
> >    ..
> >  }
> >  __finally
> >  {
> >    rs->Close();
> >  }
> >}
> >__finally
> >{
> >  delete rs;
> >}
> >
> >"Steve" <sportock@hotmail.com> �������/�������� � �������� ���������:
> >news:40f4119e$1@newsgroups.borland.com...
> >>
> >> I am instantiating tadodatasets dynamically, not using the vcl stuff to
> >drop on my form. What is the proper way to create the object and handle
> >errors and releasing memory for it? I am doing them like this.
> >>
> >> TADODataSet *rs = new TADODataSet(NULL);
> >> rs->Connection = frmFrame->adoConnection;
> >> rs->Connection->LoginPrompt = false;
> >> rs->CommandText = sql;
> >> rs->Open();
> >> rs->Close();
> >> delete rs;
> >>
> >> I just can't seem to find any example code. Thanks in advance.
> >>
> >
> >
> Thanks, when ever using these types, do the connections have to be opened
and closed explicitly? I know on recordsets, but how about adoquerys, or
adocommands when just executing a simple sql statement?
Technical Details
Message-ID: <40f66a9d@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <40f4119e$1@newsgroups.borland.com> <40f4d007$1@newsgroups.borland.com> <40f640b5$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,7efbd26a8e32ebe9
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII
From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <40f4119e$1@newsgroups.borland.com> <40f4d007$1@newsgroups.borland.com> <40f640b5$1@newsgroups.borland.com>
Subject: Re: proper form for a try/catch on an ado object
Date: Thu, 15 Jul 2004 15:29:32 +0400
Lines: 64
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 213.234.218.42
Message-ID: <40f66a9d@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1089890973 213.234.218.42 (15 Jul 2004 04:29:33 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail