FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Close ADO-connection
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Close ADO-connection
Posted: Sun Jul 14, 2013 08:51 PM
Hi,

I allways use in the beginning of my program
Code (fw): Select all Collapse
oSQL:=CreateObject("ADODB.Connection")
oSQL:ConnectionString:=ADO_SQL_Connectionstring
oSQL:Open()
...
...

and at the end
Code (fw): Select all Collapse
oSQL:close()
oSQL:=nil

and that is working very nice.

In a particual program I want to delete the SQLite-database and do

Code (fw): Select all Collapse
oSQL:close()
oSQL:=nil
ferase('.\myfile.db')

but the ferase() this returns an error -1
This mean that the file is not closed :-)

I now if a only return recordsets, I don't need to open the file like that, but I need to execute some SQL-commands (like creating tables, and other commands)
How can I close the connection completely with ADO?

Thanks
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Close ADO-connection
Posted: Sun Jul 14, 2013 09:38 PM
Marc,

Marc Vanzegbroeck wrote:
Code (fw): Select all Collapse
oSQL:=nil


This is not needed.

Marc Vanzegbroeck wrote:How can I close the connection completely with ADO?


Code (fw): Select all Collapse
oSQL:close()


Should be enough. It might be a timing issue. Try to insert a delay between close() and ferase().

EMG
Posts: 310
Joined: Mon Oct 10, 2005 05:10 AM
Re: Close ADO-connection
Posted: Sun Jul 14, 2013 10:36 PM

Hi Marc

ferase requires the full path of the filename it may not be a sql issue.

Cheers

Colin

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Close ADO-connection
Posted: Mon Jul 15, 2013 04:24 AM

I too confirm the problem.
I could not find a solution yet.

Regards



G. N. Rao.

Hyderabad, India
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: Close ADO-connection
Posted: Mon Jul 15, 2013 05:26 AM
Colin Haig wrote:Hi Marc

ferase requires the full path of the filename it may not be a sql issue.

Cheers

Colin


Colin,

This is not the problem, because it's working if I don't open the file before.
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: Close ADO-connection
Posted: Mon Jul 15, 2013 05:40 AM
Enrico Maria Giordano wrote:
Should be enough. It might be a timing issue. Try to insert a delay between close() and ferase().

EMG


Enrico,

A delay between close() and ferase() don't work :-) I even tested it with 10 seconds delay...
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Close ADO-connection
Posted: Mon Jul 15, 2013 06:34 AM
Marc,

Marc Vanzegbroeck wrote:
Enrico Maria Giordano wrote:
Should be enough. It might be a timing issue. Try to insert a delay between close() and ferase().

EMG


Enrico,

A delay between close() and ferase() don't work :-) I even tested it with 10 seconds delay...


What did you use for the delay?

EMG
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: Close ADO-connection
Posted: Mon Jul 15, 2013 07:08 AM
Enrico Maria Giordano wrote:
What did you use for the delay?

EMG


delay(100)
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Close ADO-connection
Posted: Mon Jul 15, 2013 07:51 AM
Marc,

Marc Vanzegbroeck wrote:
Enrico Maria Giordano wrote:
What did you use for the delay?

EMG


delay(100)


Try with SysWait().

EMG
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Close ADO-connection
Posted: Mon Jul 15, 2013 09:43 AM

Thanks to EMG
SysWait(100) worked for me.

Regards



G. N. Rao.

Hyderabad, India
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: Close ADO-connection
Posted: Mon Jul 15, 2013 09:59 AM
nageswaragunupudi wrote:Thanks to EMG
SysWait(100) worked for me.

Also for me :-)
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Close ADO-connection
Posted: Mon Jul 15, 2013 10:36 AM

NageswaraRao and Marc,

Great! :-)

EMG

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Close ADO-connection
Posted: Mon Jul 15, 2013 10:55 AM

very good! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Close ADO-connection
Posted: Mon Jul 15, 2013 01:46 PM

I wonder about other users having the database open thus preventing deletion. Is there a way to tell? Or, perhaps this is a temp file only created and used by one user?

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: Close ADO-connection
Posted: Mon Jul 15, 2013 01:53 PM
James Bott wrote:I wonder about other users having the database open thus preventing deletion. Is there a way to tell? Or, perhaps this is a temp file only created and used by one user?


I only use SQLite-database on stand-alone programs.
For network-versions I use MySQL. There I don't delete the database-file. Normaly I don't delete any database, but in this paricular program I want the user to be able to delete the SQLite-database, and create an other one...
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite