Destroying database object
-
I close a database using: database.OpenEx(mySql,CDatabase::noOdbcDialog) ... ...more code... database.Close(); but it remains existing. I have read it is also needed to destroy the object,, how can I do it? Thanks.
-
I close a database using: database.OpenEx(mySql,CDatabase::noOdbcDialog) ... ...more code... database.Close(); but it remains existing. I have read it is also needed to destroy the object,, how can I do it? Thanks.
Set database = Nothing (in straight asp)
"The greatest danger to humanity is humanity without an open mind."
- Ian Mariano - http://www.ian-space.com/ -
Set database = Nothing (in straight asp)
"The greatest danger to humanity is humanity without an open mind."
- Ian Mariano - http://www.ian-space.com/Well, it is an MFC app, this way: void OnExcel(CString sExcelFile)//, CString ficheroSolo) { CDatabase database; CString sDriver ;//= "MICROSOFT EXCEL DRIVER (*.XLS)"; sDriver = GetExcelDriver(); CString sSql; TRY { // Build the creation string for access without DSN sSql.Format("DRIVER={%s};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=\"%s\";DBQ=%s", sDriver, sExcelFile, sExcelFile); // Create the database (i.e. Excel sheet) if( database.OpenEx(sSql,CDatabase::noOdbcDialog) ) { // Create table structure sSql.Format( "CREATE TABLE Graficas (Fecha TEXT, Hora NUMBER,[Temperatura (ºC)] NUMBER,[Rocío (ºC)] NUMBER,[Presión (mb)] NUMBER,[Velocidad (km/h)] NUMBER,[Dirección (º)] NUMBER,Brújula TEXT)"); database.ExecuteSQL(sSql); } ...more code ...INSERT INTO, etc .... database.Close();
-
Well, it is an MFC app, this way: void OnExcel(CString sExcelFile)//, CString ficheroSolo) { CDatabase database; CString sDriver ;//= "MICROSOFT EXCEL DRIVER (*.XLS)"; sDriver = GetExcelDriver(); CString sSql; TRY { // Build the creation string for access without DSN sSql.Format("DRIVER={%s};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=\"%s\";DBQ=%s", sDriver, sExcelFile, sExcelFile); // Create the database (i.e. Excel sheet) if( database.OpenEx(sSql,CDatabase::noOdbcDialog) ) { // Create table structure sSql.Format( "CREATE TABLE Graficas (Fecha TEXT, Hora NUMBER,[Temperatura (ºC)] NUMBER,[Rocío (ºC)] NUMBER,[Presión (mb)] NUMBER,[Velocidad (km/h)] NUMBER,[Dirección (º)] NUMBER,Brújula TEXT)"); database.ExecuteSQL(sSql); } ...more code ...INSERT INTO, etc .... database.Close();
When the your function ends, the CDatabase object is destroyed because it passes out of scope. There's no need to destroy it yourself, unless you created it with
new
, in which case you'll have todelete
it."The greatest danger to humanity is humanity without an open mind."
- Ian Mariano - http://www.ian-space.com/ -
When the your function ends, the CDatabase object is destroyed because it passes out of scope. There's no need to destroy it yourself, unless you created it with
new
, in which case you'll have todelete
it."The greatest danger to humanity is humanity without an open mind."
- Ian Mariano - http://www.ian-space.com/Ok, ok. You're right. It was my mistake. Thank you, very much.