Close ADO-connection

Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Close ADO-connection

Post by Marc Vanzegbroeck »

Hi,

I allways use in the beginning of my program

Code: Select all

oSQL:=CreateObject("ADODB.Connection")
oSQL:ConnectionString:=ADO_SQL_Connectionstring
oSQL:Open()
...
...
 
and at the end

Code: Select all

oSQL:close()
oSQL:=nil
 
and that is working very nice.

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

Code: Select all

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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Close ADO-connection

Post by Enrico Maria Giordano »

Marc,
Marc Vanzegbroeck wrote:

Code: Select all

oSQL:=nil
 
This is not needed.
Marc Vanzegbroeck wrote:How can I close the connection completely with ADO?

Code: Select all

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

EMG
Colin Haig
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Re: Close ADO-connection

Post by Colin Haig »

Hi Marc

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

Cheers

Colin
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Close ADO-connection

Post by nageswaragunupudi »

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

G. N. Rao.
Hyderabad, India
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Re: Close ADO-connection

Post by Marc Vanzegbroeck »

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
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Re: Close ADO-connection

Post by Marc Vanzegbroeck »

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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Close ADO-connection

Post by Enrico Maria Giordano »

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
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Re: Close ADO-connection

Post by Marc Vanzegbroeck »

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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Close ADO-connection

Post by Enrico Maria Giordano »

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

EMG
delay(100)
Try with SysWait().

EMG
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Close ADO-connection

Post by nageswaragunupudi »

Thanks to EMG
SysWait(100) worked for me.
Regards

G. N. Rao.
Hyderabad, India
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Re: Close ADO-connection

Post by Marc Vanzegbroeck »

nageswaragunupudi wrote:Thanks to EMG
SysWait(100) worked for me.
Also for me :D
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Close ADO-connection

Post by Antonio Linares »

very good! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: Close ADO-connection

Post by James Bott »

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?
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Re: Close ADO-connection

Post by Marc Vanzegbroeck »

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
Post Reply