Close ADO-connection

Close ADO-connection

Postby Marc Vanzegbroeck » Sun Jul 14, 2013 8:51 pm

Hi,

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

and at the end
Code: Select all  Expand view  RUN
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  Expand view  RUN
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
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Close ADO-connection

Postby Enrico Maria Giordano » Sun Jul 14, 2013 9:38 pm

Marc,

Marc Vanzegbroeck wrote:
Code: Select all  Expand view  RUN
oSQL:=nil
 


This is not needed.

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


Code: Select all  Expand view  RUN
oSQL:close()


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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Close ADO-connection

Postby Colin Haig » 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
Colin Haig
 
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Re: Close ADO-connection

Postby nageswaragunupudi » Mon Jul 15, 2013 4:24 am

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

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10656
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Close ADO-connection

Postby Marc Vanzegbroeck » Mon Jul 15, 2013 5: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
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Close ADO-connection

Postby Marc Vanzegbroeck » Mon Jul 15, 2013 5: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
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Close ADO-connection

Postby Enrico Maria Giordano » Mon Jul 15, 2013 6: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
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Close ADO-connection

Postby Marc Vanzegbroeck » Mon Jul 15, 2013 7: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
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Close ADO-connection

Postby Enrico Maria Giordano » Mon Jul 15, 2013 7:51 am

Marc,

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

EMG


delay(100)


Try with SysWait().

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Close ADO-connection

Postby nageswaragunupudi » Mon Jul 15, 2013 9:43 am

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

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10656
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Close ADO-connection

Postby Marc Vanzegbroeck » Mon Jul 15, 2013 9:59 am

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

Re: Close ADO-connection

Postby Enrico Maria Giordano » Mon Jul 15, 2013 10:36 am

NageswaraRao and Marc,

Great! :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Close ADO-connection

Postby Antonio Linares » Mon Jul 15, 2013 10:55 am

very good! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Close ADO-connection

Postby James Bott » Mon Jul 15, 2013 1: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?
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Close ADO-connection

Postby Marc Vanzegbroeck » Mon Jul 15, 2013 1: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
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 101 guests