Page 1 of 1
Closedatabase when killing program....
Posted: Fri May 23, 2008 5:06 pm
by Marco2007
Hi,
wouldn`t it be good, if a Database (the connection) would be closed automatically, when you`re killing a program.
Access and PB4.10.
thanx and greetings
Marco
Posted: Sat May 24, 2008 9:03 am
by Tranquil
Normaly all resources allocated by PB are freed on exit automatically. What behaviour did you encountered? Do you also want to remove the ODBC connection?
Posted: Sat May 24, 2008 9:21 am
by Marco2007
Yep, exactly! The connection is still running...and so the database is locked...
Posted: Sat May 24, 2008 9:33 am
by Tranquil
I have many databases here at work and this does not happen here.
PB calls CloseDatabase() while exit automatically and I dont need to remove the ODBC connection from the database for editing it.
But you can try it yourself using Rings-connection on thy fly-procedures:
Code: Select all
#ODBC_ADD_DSN = 1 ; Add Data source
#ODBC_ADD_SYS_DSN = 4 ; Add SYSTEM Data source
#ODBC_CONFIG_DSN = 2 ; Configure (edit) Data source
#ODBC_REMOVE_DSN = 3 ; Remove Data source
#ODBC_REMOVE_SYS_DSN = 6 ; Remove SYSTEM Data source
Procedure DeleteConnection(Driver.s,DSN.s)
Result=OpenLibrary(1,"ODBCCP32.DLL")
If Result
lpszDriver.s=Driver
strAttributes.s = "DSN="+DSN
Result = CallFunction(1, "SQLConfigDataSource", 0,#ODBC_REMOVE_SYS_DSN,lpszDriver.s,strAttributes )
CloseLibrary(1)
If Result
ProcedureReturn 1;MessageRequester("Info","DSN Delete",0)
EndIf
EndIf
EndProcedure
DeleteConnection("Microsoft Access Driver (*.mdb)","YourDatabaseName")
Posted: Sat May 24, 2008 9:40 am
by Marco2007
Sorry, I did´t mean closing the program -> killing program from the IDE!
Posted: Sat May 24, 2008 9:51 am
by Tranquil
I tried here at work. Even if I kill the process within the IDE the connection gets closed. My thought is, that the system (Windows 2000 here) frees and releases the connection.
I dont think that PB frees alls resources on killing the process. As it says it: it kills the process, so there will be no clean up routine-calls any more.
Which OS do you use?
Edit: You may take a look on the .ldb files within the folder of you access databases. Sometimes its needed to delete them to gain admin access again on the database. (here at least once a month)
Posted: Sat May 24, 2008 10:06 am
by Marco2007
Yes, the *.ldb is not deleted, that`s why I recognized it.
I´ll always put a Isdatabase at the end of the program, but that just (of course) works with normal closing.
But while coding, there are often bugs (I see with the debugger) and so I sometimes kill the program.
> Tranquil wrote: ..once a month -> I guess this isn`t normal.
XP PB4.10
Posted: Sat May 24, 2008 10:09 am
by Tranquil
Marco2007 wrote:
> Tranquil wrote: ..once a month -> I guess this isn`t normal.
XP PB4.10
This is not normal, you are right. But this happens fast if user kill your application using the taskmanager or the system kills your process on windows shutdown course you application needs to long to exit....