Using connectionString with ADOQuery leaves connection open?

Delphi 7 using ADO to connect to an Intersystems Cache DB

I have some threads that use something like below that we noticed
the connection count kept going up with each thread created.

Uses the ConnectionString and not an ADOConnection object.

I just made a dummy program, and pasted this code into a button click to
get the same results.

{code}
 ADOQuery1.ConnectionString := 'Provider=MSDASQL.1;Persist Security Info=False;Data Source=CHECKMATE';
 ADOQuery1.Open;
 Memo1.Lines.Add(IntToStr(ADOQuery1.RecordCount));
 ADOQuery1.Close;
  // ADOQuery1.ConnectionString := ''; // uncomment this and fixes it?
{code}

I was under the impression that closing the query itself, would close the connection object? it makes to establish
the initial connection. But apparently it is not. 

If I set the ConnectionString to nothing, this appears to fix it. I see on the server side the connection appear,
then disappear. 

Comment the line back out and rerun, and the connection appears when it runs and stays there until I close
the program.

Is this to be expected? or am I missing something? or just a bug?
0
steven
12/6/2013 6:23:54 PM
embarcadero.delphi.ado 597 articles. 1 followers. Follow

13 Replies
4358 Views

Similar Articles

[PageSpeed] 13

steven wrote:

> I was under the impression that closing the query itself, would close
> the connection object?

No, because multiple queries can be attached to the same connection.  Closing 
a query is not the same thing as closing a connection.

> If I set the ConnectionString to nothing, this appears to fix it.

TADOQuery is a TCustomADODataSet descendant.  TCustomADODataSet has a reference 
to its current Connection (more accurately, it has an internal TADOCommand, 
which then has the actual TADOConnection reference).  Whether that Connection 
is an external TADOConnection or an internally created TADOConnection, TCustomADODataSet 
does not care for most operations.  However, changing the ConnectionString 
to any value, empty or otherwise, causes the current Connection to be reset. 
 Simply closing the query does not do that, as Close() does not care whether 
the Connection is external or internal.

--
Remy Lebeau (TeamB)
0
Remy
12/7/2013 2:02:50 AM
> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> steven wrote:
> 
> > I was under the impression that closing the query itself, would close
> > the connection object?
> 
> No, because multiple queries can be attached to the same connection.  Closing 
> a query is not the same thing as closing a connection.
> 
> > If I set the ConnectionString to nothing, this appears to fix it.
> 
> TADOQuery is a TCustomADODataSet descendant.  TCustomADODataSet has a reference 
> to its current Connection (more accurately, it has an internal TADOCommand, 
> which then has the actual TADOConnection reference).  Whether that Connection 
> is an external TADOConnection or an internally created TADOConnection, TCustomADODataSet 
> does not care for most operations.  However, changing the ConnectionString 
> to any value, empty or otherwise, causes the current Connection to be reset. 
>  Simply closing the query does not do that, as Close() does not care whether 
> the Connection is external or internal.
> 
> --
> Remy Lebeau (TeamB)

Thanks. 
 I figured the TADOQuery with no assigned TADOConnection would close/free/whatever
its own created TADOConnection, as nothing else but that TADOQuery can use this internally created one, and
no way to access this internally created one to close that connection made? So to me, if TADOQuery creates its own 
connection object in this case, it should expose it? or at best, if you close tadoquery, it closes the adoconnection
it made internally. Otherwise, left with TONS of open connections. 

I got around this for now, by everywhere that uses to TADOQuery with the a connectionstring set, i set it back to blank
when its done.

it needs to maintain it better.. but that is me.
0
steven
12/8/2013 6:24:25 AM
steven wrote:

> I figured the TADOQuery with no assigned TADOConnection would
> close/free/whatever its own created TADOConnection, as nothing
> else but that TADOQuery can use this internally created one, and
> no way to access this internally created one to close that connection
> made?

TADOQuery has a public Connection property, which will point to whatever 
TADOConnection the TADOQuery is actually using, internal or otherwise.

> So to me, if TADOQuery creates its own connection object in this
> case, it should expose it?

It does.

> or at best, if you close tadoquery, it closes the adoconnection
> it made internally.

No, because it does not know whether you might want to reuse the same Connection 
to run a different query.  Closing a Query is not supposed to close the Connection 
that the Query is using.

--
Remy Lebeau (TeamB)
0
Remy
12/9/2013 5:46:06 AM
> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> steven wrote:
> 
> > I figured the TADOQuery with no assigned TADOConnection would
> > close/free/whatever its own created TADOConnection, as nothing
> > else but that TADOQuery can use this internally created one, and
> > no way to access this internally created one to close that connection
> > made?
> 
> TADOQuery has a public Connection property, which will point to whatever 
> TADOConnection the TADOQuery is actually using, internal or otherwise.
> 
> > So to me, if TADOQuery creates its own connection object in this
> > case, it should expose it?
> 
> It does.
> 
> > or at best, if you close tadoquery, it closes the adoconnection
> > it made internally.
> 
> No, because it does not know whether you might want to reuse the same Connection 
> to run a different query.  Closing a Query is not supposed to close the Connection 
> that the Query is using.
> 
> --
> Remy Lebeau (TeamB)

I'll have to retry this, but the other day I was sure the TADOQuery.Connection was not assigned
when using a connection string. And trying to access it caused AV errors.

Which leads me to believe the tadoquery internally created connection can not be used by other objects?
if that is so, then the tadoquery should handle the connection object it makes better. But thats me :)
0
steven
12/9/2013 2:26:43 PM
{code}
procedure TForm1.Button1Click(Sender: TObject);
var
 q : tadoquery;
begin
 q := tadoquery.create(nil);
 q.connectionstring := 'Provider=MSDASQL.1;Persist Security Info=False;Data Source=DB1';
 q.SQL.Text := 'select * from testtable';
 q.Open;
 ShowMessage(IntToStr(q.RecordCount));
 q.Close;
 try
  q.Connection.close; /// <-- causes AV error
 except
  on e:Exception do
   begin
    ShowMessage('Error : '+e.message);  /// <--- Error : Access violation at address 00469696 in module 'Project1.exe'. Read of address 00000000
   end;
 end;
 q.ConnectionString := '';
 q.free;
end;
{code}

Edited by: steven chesser on Dec 9, 2013 6:43 AM
0
steven
12/9/2013 2:43:45 PM
Anyone else got any ideas on this? 

I used XE5 and same results. 

just seems odd to me is all.
0
steven
12/10/2013 5:40:14 PM
steven chesser wrote:

> {code}
> procedure TForm1.Button1Click(Sender: TObject);
> var
>  q : tadoquery;
> begin
>  q := tadoquery.create(nil);
>  q.connectionstring := 'Provider=MSDASQL.1;Persist Security
> Info=False;Data Source=DB1';  q.SQL.Text := 'select * from testtable';
>  q.Open;
>  ShowMessage(IntToStr(q.RecordCount));
>  q.Close;
>  try
>   q.Connection.close; /// <-- causes AV error
>  except
>   on e:Exception do
>    begin
>     ShowMessage('Error : '+e.message);  /// <--- Error : Access
> violation at address 00469696 in module 'Project1.exe'. Read of
> address 00000000    end;  end;
>  q.ConnectionString := '';
>  q.free;
> end;
> {code}
> 
> Edited by: steven chesser on Dec 9, 2013 6:43 AM

If you did not assign a connection then that property will be nil thus
the A/V.

-- 
Ray
0
no_s_p_a_m
12/11/2013 4:31:19 AM
steven chesser wrote:

> Delphi 7 using ADO to connect to an Intersystems Cache DB
> 
> I have some threads that use something like below that we noticed
> the connection count kept going up with each thread created.
> 
> Uses the ConnectionString and not an ADOConnection object.
> 
> I just made a dummy program, and pasted this code into a button click
> to get the same results.
> 
> {code}
>  ADOQuery1.ConnectionString := 'Provider=MSDASQL.1;Persist Security
> Info=False;Data Source=CHECKMATE';  ADOQuery1.Open;
>  Memo1.Lines.Add(IntToStr(ADOQuery1.RecordCount));
>  ADOQuery1.Close;
>   // ADOQuery1.ConnectionString := ''; // uncomment this and fixes it?
> {code}
> 
> I was under the impression that closing the query itself, would close
> the connection object? it makes to establish the initial connection.
> But apparently it is not.
> 
> If I set the ConnectionString to nothing, this appears to fix it. I
> see on the server side the connection appear, then disappear. 
> 
> Comment the line back out and rerun, and the connection appears when
> it runs and stays there until I close the program.
> 
> Is this to be expected? or am I missing something? or just a bug?

By any chance are you actually referring to the SQL connection that you
would see from sp_who for example?  In that case you may need to tweak
the connection pool options for the connection string to your desired
behavior.  Also if I remember correctly if you free your ADO connection
(in this case just your query) that should release any sleeping
connections lingering from your query.

-- 
Ray
0
no_s_p_a_m
12/11/2013 4:46:13 AM
> {quote:title=Raymond Alexander wrote:}{quote}
> steven chesser wrote:
> 
> > {code}
> > procedure TForm1.Button1Click(Sender: TObject);
> > var
> >  q : tadoquery;
> > begin
> >  q := tadoquery.create(nil);
> >  q.connectionstring := 'Provider=MSDASQL.1;Persist Security
> > Info=False;Data Source=DB1';  q.SQL.Text := 'select * from testtable';
> >  q.Open;
> >  ShowMessage(IntToStr(q.RecordCount));
> >  q.Close;
> >  try
> >   q.Connection.close; /// <-- causes AV error
> >  except
> >   on e:Exception do
> >    begin
> >     ShowMessage('Error : '+e.message);  /// <--- Error : Access
> > violation at address 00469696 in module 'Project1.exe'. Read of
> > address 00000000    end;  end;
> >  q.ConnectionString := '';
> >  q.free;
> > end;
> > {code}
> > 
> > Edited by: steven chesser on Dec 9, 2013 6:43 AM
> 
> If you did not assign a connection then that property will be nil thus
> the A/V.
> 
> -- 
> Ray

That is correct.. i was just showing to remy how using a connectionstring does not create a connection that
is accessable via the .connection
0
steven
12/11/2013 4:46:19 PM
> {quote:title=Raymond Alexander wrote:}{quote}
> steven chesser wrote:
> 
> > Delphi 7 using ADO to connect to an Intersystems Cache DB
> > 
> > I have some threads that use something like below that we noticed
> > the connection count kept going up with each thread created.
> > 
> > Uses the ConnectionString and not an ADOConnection object.
> > 
> > I just made a dummy program, and pasted this code into a button click
> > to get the same results.
> > 
> > {code}
> >  ADOQuery1.ConnectionString := 'Provider=MSDASQL.1;Persist Security
> > Info=False;Data Source=CHECKMATE';  ADOQuery1.Open;
> >  Memo1.Lines.Add(IntToStr(ADOQuery1.RecordCount));
> >  ADOQuery1.Close;
> >   // ADOQuery1.ConnectionString := ''; // uncomment this and fixes it?
> > {code}
> > 
> > I was under the impression that closing the query itself, would close
> > the connection object? it makes to establish the initial connection.
> > But apparently it is not.
> > 
> > If I set the ConnectionString to nothing, this appears to fix it. I
> > see on the server side the connection appear, then disappear. 
> > 
> > Comment the line back out and rerun, and the connection appears when
> > it runs and stays there until I close the program.
> > 
> > Is this to be expected? or am I missing something? or just a bug?
> 
> By any chance are you actually referring to the SQL connection that you
> would see from sp_who for example?  In that case you may need to tweak
> the connection pool options for the connection string to your desired
> behavior.  Also if I remember correctly if you free your ADO connection
> (in this case just your query) that should release any sleeping
> connections lingering from your query.
> 
> -- 
> Ray


Another Update.

Found one more rouge call from years ago that would change the connectionString.. sigh. Finally have that all cleaned up.

For what I am working with, they want connections to totally close out, leaving none open when any db calling is finished. Just
what they require of me. 

So I have it this way.

The single TADOConnection.ConnectionString = Provider=MSDASQL.1;Persist Security Info=False;Data Source=mydb;OLE DB Services = -2

The ole DB services = -2 is suppose to disable ado pooling and appears to be working.

The next change, every TADOQuery has an AfterClose event set, to where it will call the ADOConnection object its connected to, to close.

This has cured most of the problems. I have gone down from have 25+ connections open, down to just 1, which will eventually go away.

The problem I have now is TADOStoredProc's don't call AfterClose when you do a ExecProc; call. And there appears to be no AfterExecute
event. Be nice if there was, as I wouldn't have to update a bunch of code to have a tadoconnection.close; call.  Just have it one place. 

If any ideas how to get an event set so when execproc is called, it gets triggered, would be nice :)
0
steven
12/11/2013 5:12:40 PM
> {quote:title=steven chesser wrote:}{quote}
> > {quote:title=Raymond Alexander wrote:}{quote}
> > steven chesser wrote:
> > 
> > > Delphi 7 using ADO to connect to an Intersystems Cache DB
> > > 
> > > I have some threads that use something like below that we noticed
> > > the connection count kept going up with each thread created.
> > > 
> > > Uses the ConnectionString and not an ADOConnection object.
> > > 
> > > I just made a dummy program, and pasted this code into a button click
> > > to get the same results.
> > > 
> > > {code}
> > >  ADOQuery1.ConnectionString := 'Provider=MSDASQL.1;Persist Security
> > > Info=False;Data Source=CHECKMATE';  ADOQuery1.Open;
> > >  Memo1.Lines.Add(IntToStr(ADOQuery1.RecordCount));
> > >  ADOQuery1.Close;
> > >   // ADOQuery1.ConnectionString := ''; // uncomment this and fixes it?
> > > {code}
> > > 
> > > I was under the impression that closing the query itself, would close
> > > the connection object? it makes to establish the initial connection.
> > > But apparently it is not.
> > > 
> > > If I set the ConnectionString to nothing, this appears to fix it. I
> > > see on the server side the connection appear, then disappear. 
> > > 
> > > Comment the line back out and rerun, and the connection appears when
> > > it runs and stays there until I close the program.
> > > 
> > > Is this to be expected? or am I missing something? or just a bug?
> > 
> > By any chance are you actually referring to the SQL connection that you
> > would see from sp_who for example?  In that case you may need to tweak
> > the connection pool options for the connection string to your desired
> > behavior.  Also if I remember correctly if you free your ADO connection
> > (in this case just your query) that should release any sleeping
> > connections lingering from your query.
> > 
> > -- 
> > Ray
> 
> 
> Another Update.
> 
> Found one more rouge call from years ago that would change the connectionString.. sigh. Finally have that all cleaned up.
> 
> For what I am working with, they want connections to totally close out, leaving none open when any db calling is finished. Just
> what they require of me. 
> 
> So I have it this way.
> 
> The single TADOConnection.ConnectionString = Provider=MSDASQL.1;Persist Security Info=False;Data Source=mydb;OLE DB Services = -2
> 
> The ole DB services = -2 is suppose to disable ado pooling and appears to be working.
> 
> The next change, every TADOQuery has an AfterClose event set, to where it will call the ADOConnection object its connected to, to close.
> 
> This has cured most of the problems. I have gone down from have 25+ connections open, down to just 1, which will eventually go away.
> 
> The problem I have now is TADOStoredProc's don't call AfterClose when you do a ExecProc; call. And there appears to be no AfterExecute
> event. Be nice if there was, as I wouldn't have to update a bunch of code to have a tadoconnection.close; call.  Just have it one place. 
> 
> If any ideas how to get an event set so when execproc is called, it gets triggered, would be nice :)

Or would I just tack this onto the ADOConnection.onExecuteComplete to close itself? Going to try that.
0
steven
12/11/2013 5:16:34 PM
steven chesser wrote:

> > {quote:title=Raymond Alexander wrote:}{quote}
> > steven chesser wrote:
> > 
> > > Delphi 7 using ADO to connect to an Intersystems Cache DB
> > > 
> > > I have some threads that use something like below that we noticed
> > > the connection count kept going up with each thread created.
> > > 
> > > Uses the ConnectionString and not an ADOConnection object.
> > > 
> > > I just made a dummy program, and pasted this code into a button
> > > click to get the same results.
> > > 
> > > {code}
> > >  ADOQuery1.ConnectionString := 'Provider=MSDASQL.1;Persist
> > > Security Info=False;Data Source=CHECKMATE';  ADOQuery1.Open;
> > >  Memo1.Lines.Add(IntToStr(ADOQuery1.RecordCount));
> > >  ADOQuery1.Close;
> > >   // ADOQuery1.ConnectionString := ''; // uncomment this and
> > > fixes it?  {code}
> > > 
> > > I was under the impression that closing the query itself, would
> > > close the connection object? it makes to establish the initial
> > > connection.  But apparently it is not.
> > > 
> > > If I set the ConnectionString to nothing, this appears to fix it.
> > > I see on the server side the connection appear, then disappear. 
> > > 
> > > Comment the line back out and rerun, and the connection appears
> > > when it runs and stays there until I close the program.
> > > 
> > > Is this to be expected? or am I missing something? or just a bug?
> > 
> > By any chance are you actually referring to the SQL connection that
> > you would see from sp_who for example?  In that case you may need
> > to tweak the connection pool options for the connection string to
> > your desired behavior.  Also if I remember correctly if you free
> > your ADO connection (in this case just your query) that should
> > release any sleeping connections lingering from your query.
> > 
> > -- 
> > Ray
> 
> 
> Another Update.
> 
> Found one more rouge call from years ago that would change the
> connectionString.. sigh. Finally have that all cleaned up.
> 
> For what I am working with, they want connections to totally close
> out, leaving none open when any db calling is finished. Just what
> they require of me.
> 
> So I have it this way.
> 
> The single TADOConnection.ConnectionString =
> Provider=MSDASQL.1;Persist Security Info=False;Data Source=mydb;OLE
> DB Services = -2
> 
> The ole DB services = -2 is suppose to disable ado pooling and
> appears to be working.
> 
> The next change, every TADOQuery has an AfterClose event set, to
> where it will call the ADOConnection object its connected to, to
> close.
> 
> This has cured most of the problems. I have gone down from have 25+
> connections open, down to just 1, which will eventually go away.
> 
> The problem I have now is TADOStoredProc's don't call AfterClose when
> you do a ExecProc; call. And there appears to be no AfterExecute
> event. Be nice if there was, as I wouldn't have to update a bunch of
> code to have a tadoconnection.close; call.  Just have it one place.
> 
> If any ideas how to get an event set so when execproc is called, it
> gets triggered, would be nice :)

There is a KeepConnection property on the connection object.  Try
setting it to false to see if it helps your situation.

-- 
Ray
0
no_s_p_a_m
12/11/2013 6:14:55 PM
> {quote:title=Raymond Alexander wrote:}{quote}
> steven chesser wrote:
> 
> > > {quote:title=Raymond Alexander wrote:}{quote}
> > > steven chesser wrote:
> > > 
> > > > Delphi 7 using ADO to connect to an Intersystems Cache DB
> > > > 
> > > > I have some threads that use something like below that we noticed
> > > > the connection count kept going up with each thread created.
> > > > 
> > > > Uses the ConnectionString and not an ADOConnection object.
> > > > 
> > > > I just made a dummy program, and pasted this code into a button
> > > > click to get the same results.
> > > > 
> > > > {code}
> > > >  ADOQuery1.ConnectionString := 'Provider=MSDASQL.1;Persist
> > > > Security Info=False;Data Source=CHECKMATE';  ADOQuery1.Open;
> > > >  Memo1.Lines.Add(IntToStr(ADOQuery1.RecordCount));
> > > >  ADOQuery1.Close;
> > > >   // ADOQuery1.ConnectionString := ''; // uncomment this and
> > > > fixes it?  {code}
> > > > 
> > > > I was under the impression that closing the query itself, would
> > > > close the connection object? it makes to establish the initial
> > > > connection.  But apparently it is not.
> > > > 
> > > > If I set the ConnectionString to nothing, this appears to fix it.
> > > > I see on the server side the connection appear, then disappear. 
> > > > 
> > > > Comment the line back out and rerun, and the connection appears
> > > > when it runs and stays there until I close the program.
> > > > 
> > > > Is this to be expected? or am I missing something? or just a bug?
> > > 
> > > By any chance are you actually referring to the SQL connection that
> > > you would see from sp_who for example?  In that case you may need
> > > to tweak the connection pool options for the connection string to
> > > your desired behavior.  Also if I remember correctly if you free
> > > your ADO connection (in this case just your query) that should
> > > release any sleeping connections lingering from your query.
> > > 
> > > -- 
> > > Ray
> > 
> > 
> > Another Update.
> > 
> > Found one more rouge call from years ago that would change the
> > connectionString.. sigh. Finally have that all cleaned up.
> > 
> > For what I am working with, they want connections to totally close
> > out, leaving none open when any db calling is finished. Just what
> > they require of me.
> > 
> > So I have it this way.
> > 
> > The single TADOConnection.ConnectionString =
> > Provider=MSDASQL.1;Persist Security Info=False;Data Source=mydb;OLE
> > DB Services = -2
> > 
> > The ole DB services = -2 is suppose to disable ado pooling and
> > appears to be working.
> > 
> > The next change, every TADOQuery has an AfterClose event set, to
> > where it will call the ADOConnection object its connected to, to
> > close.
> > 
> > This has cured most of the problems. I have gone down from have 25+
> > connections open, down to just 1, which will eventually go away.
> > 
> > The problem I have now is TADOStoredProc's don't call AfterClose when
> > you do a ExecProc; call. And there appears to be no AfterExecute
> > event. Be nice if there was, as I wouldn't have to update a bunch of
> > code to have a tadoconnection.close; call.  Just have it one place.
> > 
> > If any ideas how to get an event set so when execproc is called, it
> > gets triggered, would be nice :)
> 
> There is a KeepConnection property on the connection object.  Try
> setting it to false to see if it helps your situation.
> 
> -- 
> Ray

Thanks. I totally forgot about that property. True by default.

That appears to easily fix my connection problems when using a TADConnection for everything to use.  

I thank you very much :)

Now to figure out the ones that don't use a tadoconnection, and uses a connectionstring. Unless the connectionstring := ''; is the fix and just
deal with it.
0
steven
12/11/2013 6:36:39 PM
Reply:

Similar Artilces:

Using connectionString Name to open a connection by code
 When I bound data to a control a connection string is created in web.config, like this:<connectionStrings> <add name="backoffDB" connectionString="Data Source=cwcc-chn-matrix;Initial Catalog=backoff;User ID=..." providerName="System.Data.SqlClient"/> </connectionStrings> If I need to open this same connection by code inside a page, how can I reuse here the connection string created inside de web.config? I suppose I can use something like:Dim Conn2 As SqlConnection   Cone2 = New SqlConnection(<% connectiosstrings: backoff...

Open Server connections leave filedescriptor open
This is a multi-part message in MIME format. --------------75077340196BEF0FA70298DF Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I hope it's ok to ask openserver questions in this forum. I've noticed that whenever you make a client connection to an open-server product (such as Historical Server, or Monitor Server, or your own open server app) the connection uses a filedescriptor from the OS, and never releases it, even after you disconnect. This means that I can quickly run out of descriptors in the file-table and have to reboot my OS. I&...

"Object was open" error when using ADO to connect to SQL Server CE 3.5
Hi all, I'm hoping someone can help me with this problem. I am trying to connect to a SQL Compact file using the following ADO commands. {code} Query := TADOQuery.Create(nil); Connection := TADOConnection.Create(nil); Connection.ConnectionString := 'Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; Data Source=c:\temp\test.sdf;'; Connection.LoginPrompt := False; Query.Connection := Connection; Query.SQL.Text := 'SELECT * FROM INFORMATION_SCHEMA.TABLES'; Query.Open; {code} When the {code} Query.Open {code} is executed I get the er...

Leave the Connection open or always open and close immediately?
Hi there,   I got an approach like that: 1) Read something from DB - check the value, if true stop if false go on2) Read the second Value (another SQL Statement) - check the value etc. Now I could open the connection at 1) and if I have to go to 2) I leave the connection open and use the same connection at 2). Is it ok to do that? The other scenario would be opening a connection at 1), immediately close it after I read the value and open a new connection at 2). Thanks for the input!Andreas Kraus on .NET Cant you move the logic to the DB?***********************Dinakar NethiLife i...

ASA7 ADO & Delphi ADO ?? Anyone is using it?
Any comments? Is it working? Any Problems? Thanks Hi, PR <noemail@no.com> schrieb in im Newsbeitrag: BoTThJaq$GA.89@forums.sybase.com... > Any comments? Is it working? Any Problems? I tried to connect to ASA7 via the new OLE DB - Provider and ADOExpress from Delphi 5.01. No chance. Only the error message 'Invalid Enum Value'. About the new provider I haven't heard anything good until now... Regards Frank Frank, I've experienced the same problem with the ASA 7 OLEDB Provider. I'm not sure if this is a bug in the AsaProvider or Delp...

Opening a table is slow using ADO, but not when using BDE
I have the following code that opens a fairly small SQL Server database table (only 30,000 records): TADOTable* taDummy = new TADOTable(this); taDummy->Connection = ADOConnection1; taDummy->TableName = "MyTable"; taDummy->Open(); taDummy->Close(); delete taDummy;  The "taDummy->Open();" line takes over thirty whole seconds to execute, which is unacceptable. However, if I change the code to use BDE: TTable* taDummy = new TTable(this); taDummy->DatabaseName = "MyDatabaseName"; taDummy->TableName = "MyTable"; ta...

Leaving a connection open?
With the code shown below, am I leaving an open connection when I assign the datareader to the data grid. As I didn't create, use, then close an actual DataReader instance (thereby activating the behaviour - I think), I'm left wondering I'm leaving a connection open from the component. Thanks in advance for your input, Adam '********page code behind*************** Dim oUserDb As New CfssUserDB() dgUsers.DataSource = oUserDb.GetUsers() dgUsers.DataBind() '********end page code behind*********** '********component code**************** Public Function GetUsers()...

Leaving a connection open
How terrible is the code below?  How do I leave the connection open  and not have to close it at each iteration?set { foreach(string OneTag in value) { SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlExpress"].ConnectionString); SqlCommand myCommand = new SqlCommand("cx_contest_set_tags", myConnection); // Add Parameters to SPROC SqlParameter parameterContestID = new SqlParameter("@ContestID", SqlDbType.Int); ...

If I use javascript in my pages, can I still use ADO to connect to SQL server?
I'm not exactly sure what I'm doing here.  (I'm sure it shows)  I want to start using javascript and ajax in my ASP.net pages, but am currently using ADO (I think) to communicate with my SQL server.  Here's a sample script..   Dim objConn As New SqlConnection(ConfigurationSettings.AppSettings("DSN")) Dim objCmd As SqlCommand Dim objRdr As SqlDataReader  Sub LoadMenubar()  Try   objConn.Open()   objCmd = New SqlCommand("SELECT * FROM Menubar ORDER BY Priority", objConn) &...

test for open connection before connection.open command
Hi I am trying to work together a peice of code that will basically state: If MyCon.Open Then 'do nothing Else MyCon.Open() End If This is because occasionally the SQL.ExecuteReader() occasionally times out and when the user trys again the page errors and states that the MyCon is already open. Has anyone had to deal with this before? Thanks for any help, Skippy. Try this - If MyCon.state = ConnectionState.open Then 'do nothing else ... In fact, if you require only to check connection is open and if not open the connection then fo...

Using ADO to connect to SQL Server 2005 or 2008 (Express and standard) using Windows Authentication
Hi, I apologize in advance if this is an overly simple question or I have simply overlooked the obvious. With the current project (it's client server not n-tier) I'm on, we usually connect using SQL Server authentication. We now have a customer that would like to us to connect to SQL server using Windows Authentication. The customer would like to control all access to SQL server using Active Directory rather than us having the username and password on the client side connecting via SQL Server Authentication. The app is still in D5 (don't ask ;) ), with all t...

When using MS-ADO to connect to ASE using ASE OLEDB/ODBC driver the record count is -1
Hi VB 6 application connecting to ASE 12.5 (NT) using OLEDB/ODBC drivers. Gets a problem. He retrieve rows from the database - WORKS Fine!!! But as soon as he wants to see how many rows was returned the recordcount returns -1. He gets this problem connecting using ODBC and OLEDB. He gets the recordcount from the recordset object's recordcount property. This is what I found on the MSDN online manuals: RecordCount Property - ADO Indicates the current number of records in a Recordset object. Applies To Recordset Remarks Use the RecordCount property to find out how many r...

To use or not to use Delphi
Sadly, it seems to me that there is a sort of race between the two threads, for and against using Delphi in new projects, with more or less the same users posting in both threads. Arguments are fiercely debated in both camps. Borland had their own vision. As a community, now that Delphi has changed ownership I believe we should try to be more consistent, more clear, and more articulate in what we expect from Embercadero in terms of Delphi. We can contribute to keeping Delphi alive and moving in the right direction. "Laurent Cocea" schrieb: > Sadly, it seems to me that there is a sort of race ... <snip> Some people go fishing, some go to the movies, some like to take long walks on the beach, and then some like to type their fingers bloody discussing totally irrelevant issues on public Newsgroups. And my wife likes to watch soap operas and follow posts from a forum where new-baked parents are discussing their kids-issues. Everyone needs a hobby :-) Regards, Danijel Laurent Cocea wrote: > Sadly, it seems to me that there is a sort of race between the two > threads They're essentially the same thread with a little more trolling in one than the other. Lots of free time over the holidays and all. I think the discussion in general is a good thing, though. Help remind people why a tool like Delphi is worth while, and maybe even shed some light on some of the things that still need attention. I still learn about ...

The connection is already open and the connection state is connecting.
Hello, I am getting this error time to time randomly. My web application is built on asp.net 3.5 which uses ODBC 5.1 driver to connect to mysql database. I have a separate database class which handles the connection, execute, fetching and all. The application runs fine for sometime then suddenly the users start getting this error after which the application fails to insert select from database. I have posted in this forum couple of times now and no one is really contributing or helping me. Please..Any help will be highly appreciated.. Many thanks, Viv The database abstract loo...

Will this leave any connections open?
Hey folks, I'm looking to create my own Data helper.  I know, I know I'm reinventing the wheel because there's stuff out there, but I want to build from scratch.  Anyway, do you see a problem with connections being left open here? ' here's the helper Public Overrides Function ExecuteReader(ByVal connectionKey As String, ByVal sprocName As String) As DbDataReader Dim connection As New SqlConnection(ConfigurationManager.ConnectionStrings(connectionKey).ConnectionString) Dim command As New SqlCommand(sprocName, connection) ...

At what throughput should I leave a connection open ?
I am used to writing applications that hit the database "every so often" and am happy with opening and closing the connection to SQL Server for each one. I am now writing an application that monitors a table where rows are written to it by a 3rd party application at possibly several rows per second. My job is to "pickup" those rows, analyse the data and move them to different tables. This will be done with a timer which is currently set to tick every second. My question is: At what stage should I start to think about keeping open a permanent connection to the databa...

Leave DB Connection Open
Hello, I have always closed my db connections asap after opening them and have always thought this was the best practice.  But now I am wondering if I can just leave the connection open. I created a windows service which runs on a timer and executes every 5 seconds.  The problem is that the code takes longer than that to process and the code may be executing three times at once. Im worried that since I use the same connection each time the code executes that a connection opened by the first run through may be closed or reopened by the second or third running of the code resulting ...

Convert Delphi 5 ADO App to Delphi 2007 ADO.NET
I have an appliction tha that is writen in Delphi 5 with ADOConnetion, ADOTable, and ADOQuery components. I need to upgrade to Delphi 2007 and use ADO.NET. I have the program building in with Delphi 2007. Is there anything I need to do to convert the ADO to ADO.NET? > I need to upgrade to Delphi 2007 and use ADO.NET. Why ? -- With best regards, Dmitry Arefiev AnyDAC (www.anydac.com) - Oracle, MS SQL Server, IBM DB2, MySQL, Firebird, Interbase, PostgreSQL, Sybase ASA, SQLite, MS Access, DBX, ODBC, InMem - universal high-speed native data access engine Reasons for change: - We already own the Delphi 2007. - We have existing product (code) what was created in Delphi 5. - We are wanting to update to the newer version and convert to the ADO.NET connection instead of the ADO. - I am being told to upgrade becuase ADO has issues with locking up machines and meno when used with SQL on very large datasets. Do you know what I need to do to convert the existing connections in ADO to ADO.NET? > {quote:title=Dmitry Arefiev wrote:}{quote} > > I need to upgrade to Delphi 2007 and use ADO.NET. > > Why ? > > -- > With best regards, > Dmitry Arefiev > AnyDAC (www.anydac.com) - Oracle, MS SQL Server, IBM DB2, MySQL, > Firebird, Interbase, PostgreSQL, Sybase ASA, SQLite, MS Access, DBX, > ODBC, InMem - universal high-speed native data access engine Unitime Development wrote: > I need to upgr...

Single open connection vs connection pool (opening and closing each time)
I see that log4net use single open connection instead of connection pool. They don't open and close the connection each time they just do it once in the beginning.  What are the risks of such approach in a multythreaded environment?  What can happen if two threads want to use the connection at the same time?  Is there a risk associated with that?  The fact is that if using just a single connection there is a performance benefit, then what is the down side? Or we are just wrong by doint this? using(var c = new SqlConnection(str)){   // use connection ......

Orphaned connections using VB6/ADO
I'm connecting to an ASA 7 database using the OLEDB provider in ADO VB6. After closing a database connection, Sybase still thinks there is a connection (I'm checking in Sybase Central.) Here is the code, very standard stuff: Private Sub OpenDB() Dim cdTemp As New ADODB.Command cnScanning.Mode = adModeReadWrite Or adModeShareDenyNone cnScanning.ConnectionString = "Provider=ASAProv.70;uid=DBA;pwd=sql;eng=" & szDatabaseServer & ";dbn=" & szDatabaseName & ";" If cnScanning.State = adStateClosed Then cn...

How to connect pragrammatically to Sybase using ADO?
Hi, all. I'm trying to programmatically connect to a Sybase database using ADO. How do I do that? Is setting up a DSN and use it for connection the only way? Thx for the help. Min. ...

Deploying Delphi software which uses ADO
Hi what needs to deployed and provided by Installaware type packages to get Delphi-based programs that use ADO to install on Windows 7 32 bit and 64 bit computers? When Googling for stuff I keep getting older information plus some comments that the Jet Engine is no longer fully supported for Windows 7 environments. Suggestions or links to good descriptions would be appreciated. Bruce On 2012-09-19 16:13:51, Bruce Eglington wrote: > what needs to deployed and provided by Installaware type packages > to get Delphi-based programs that use ADO to install on Windows 7 32...

Error openning connection using EnterpriseServices.
The code below throws an exception on method AseConnection.Open if any TransactionOption different from NotSupported is specified. The exception message is "The token datastream length was not correct. This is an internal protocol error". The version of ADO.NET provider is 1.15.105.0. The version of .NET Framework is 2.0.50727. public List<Table> FindAll() { List<Table> result = new List<Table>(); ServiceConfig cfg = new ServiceConfig(); cfg.Transaction = TransactionOption.Required; cfg.IsolationLevel = TransactionIsolationLevel.ReadU...

embox/edirutil leaving open connection
Hi, I've noticed that on our servers every embox/edirutil backup job leaves an open connection. So after a couple of days or weeks there are open connections for each day the backup has taken place. They don't consume licenses, so no real problem at the moment, but I don't think these connections are intended to be left open. The effect is the same whether the backup is made interactively or from the command line. Servers are Netware 6.5 SP3 and SP5. Any suggestions? Thanks in advance. Bye, Frank On Sun, 20 Aug 2006 11:05:59 +0000, Frank Langner wrote: ...

Web resources about - Using connectionString with ADOQuery leaves connection open? - embarcadero.delphi.ado

Highest Voted 'entity-framework' Questions - Stack Overflow
Q&A for professional and enthusiast programmers

Bazaar - Alternative Windows Phone marketplace for homebrew applications DotNetNuke
Message: System.Data.SqlClient.SqlException (0x80131904): Could not allocate space for object 'dbo.EventLog'.'PK_EventLogMaster' in database ...

C# dotnet SQL editor (codebehind side)
In the first post C# dotnet SQL editor (webform side) I've explained the purpose of this "exercise" and suggested a webform proposal for this ...

Specifying the timeout for SSIS 2012 package execution
This is a follow up to my post from last year about executing packages in the SSIS catalog programmatically. The main problem that makes it unworkable ...

DotNetNuke
Message: System.Data.SqlClient.SqlException (0x80131904): Could not allocate space for object 'dbo.EventLog'.'PK_EventLogMaster' in database ...

Running a .NET app against a Postgres database in Docker
... the Postgres connection string in your web.config to point to it. You can leave the username and password the same: name= "Postgres" connectionString= ...

Latest Updates
Latest Updates - Free source code and tutorials for Software developers and Architects.; Updated: 15 Feb 2013

Delicious
Keep, share, and discover the best of the Web using Delicious, the world's leading social bookmarking service.

Developer.com: Your Home for Java and Open Source Development Knowledge - Security
Developer.com is your source for Java and Open Source information, how-tos, news, and reports. Developer.com is the place for the latest programming ...

Goodies - ENTERPRISEYNESS
Here are some great resources, tools, and sites I have come across while researching my different projects. videos and conferences Mix 2011 Videos ...

Resources last updated: 2/19/2016 10:02:36 PM