Closedatabase when killing program....

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Closedatabase when killing program....

Post 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
PureBasic for Windows
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post 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?
Tranquil
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Post by Marco2007 »

Yep, exactly! The connection is still running...and so the database is locked...
PureBasic for Windows
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post 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")

Tranquil
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Post by Marco2007 »

Sorry, I did´t mean closing the program -> killing program from the IDE!
PureBasic for Windows
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post 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)
Tranquil
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Post 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
PureBasic for Windows
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

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