Modified:
trunk/MYODBCIns/MYODBCInsLib/MYODBCInsDataSource.cpp
trunk/MYODBCIns/MYODBCInsTest/MYODBCInsTest.cpp
trunk/MYODBCIns/include/MYODBCInsDataSource.h
trunk/MYODBCSetup/MYODBCSetupLib/ConfigDSNW.cpp
trunk/MYODBCSetup/MYODBCSetupLib/MYODBCSetupDataSourceDialog.cpp
Log:
- fixed a bug where datasource values were being cleared and DRIVER value was being lost
- improved error reporting (save/restore error when SQLSetConfigMode is clearing errors
before we want them to be cleared)
- basic GUI seems to be ready but expect some more changes for SQLDriverConnect
Modified: trunk/MYODBCIns/MYODBCInsLib/MYODBCInsDataSource.cpp
===================================================================
--- trunk/MYODBCIns/MYODBCInsLib/MYODBCInsDataSource.cpp 2006-06-22 19:33:17 UTC (rev 361)
+++ trunk/MYODBCIns/MYODBCInsLib/MYODBCInsDataSource.cpp 2006-06-22 21:30:26 UTC (rev 362)
@@ -380,8 +380,20 @@
bReturn = true;
doReadExit1:
- SQLSetConfigMode( nScopeToRestore );
+ /* lets not loose the error message while we restore our scope */
+ {
+ QString stringError;
+ DWORD nError = 0;
+ if ( !bReturn )
+ MYODBCIns::getError( 1, &nError, stringError );
+
+ SQLSetConfigMode( nScopeToRestore );
+
+ if ( !bReturn && !stringError.isEmpty() )
+ MYODBCIns::setError( stringError, nError );
+ }
+
MYODBCDbgReturn3( "%d", bReturn );
}
@@ -416,11 +428,13 @@
if ( !SQLSetConfigMode( (UWORD)nScope ) )
MYODBCDbgReturn3( "%d", false )
- /*
- SQLWriteDSNToIni is *supposed* to replace any existing DSN
- with same name but fails (at least on unixODBC) to do so.
- So we ensure that any existing DSN with same name is removed
- with the following call.
+ /*!
+ \internal ODBC RULE
+
+ SQLWriteDSNToIni is *supposed* to replace any existing DSN with same name but
fails to
+ do so. So we ensure that any existing DSN with same name is removed with the
following call.
+ This is particularly important when saving attributes which have an empty value
but used
+ to have a non-empty value as empty value attributes are ignored during save.
*/
if ( !SQLRemoveDSNFromIni( stringName.utf16() ) )
goto doWriteExit1;
@@ -446,8 +460,20 @@
bReturn = true;
doWriteExit1:
- SQLSetConfigMode( nScopeToRestore );
+ /* lets not loose the error message while we restore our scope */
+ {
+ QString stringError;
+ DWORD nError = 0;
+ if ( !bReturn )
+ MYODBCIns::getError( 1, &nError, stringError );
+
+ SQLSetConfigMode( nScopeToRestore );
+
+ if ( !bReturn && !stringError.isEmpty() )
+ MYODBCIns::setError( stringError, nError );
+ }
+
MYODBCDbgReturn3( "%d", bReturn );
}
Modified: trunk/MYODBCIns/MYODBCInsTest/MYODBCInsTest.cpp
===================================================================
--- trunk/MYODBCIns/MYODBCInsTest/MYODBCInsTest.cpp 2006-06-22 19:33:17 UTC (rev 361)
+++ trunk/MYODBCIns/MYODBCInsTest/MYODBCInsTest.cpp 2006-06-22 21:30:26 UTC (rev 362)
@@ -94,6 +94,18 @@
QVERIFY( hashKeywordValues.value( "DSN" ) == "my dsn" );
QVERIFY( hashKeywordValues.value( "DATABASE" ) == "my database" );
+ /* does MYODBCInsDataSource load ok? */
+ {
+ MYODBCInsDataSource datasource;
+ datasource.setScope( MYODBCInsDataSource::DATASOURCE_SCOPE_BOTH );
+ if ( !datasource.setAttributes( hashKeywordValues, true, false ) )
+ QFAIL( "setAttributes failed" );
+ QVERIFY( datasource.getDRIVER() == "my driver" );
+ QVERIFY( datasource.getName() == "my dsn" );
+ QVERIFY( datasource.getDATABASE() == "my database" );
+ QVERIFY( datasource.getDESCRIPTION().isNull() );
+ }
+
/* DELIM_SEMI string - as per SQLDriverConnect() */
hashKeywordValues.clear();
wcscpy( szzAttributes, TEXT("DRIVER=my driver;DSN=my dsn;DATABASE=my database") );
Modified: trunk/MYODBCIns/include/MYODBCInsDataSource.h
===================================================================
--- trunk/MYODBCIns/include/MYODBCInsDataSource.h 2006-06-22 19:33:17 UTC (rev 361)
+++ trunk/MYODBCIns/include/MYODBCInsDataSource.h 2006-06-22 21:30:26 UTC (rev 362)
@@ -134,8 +134,8 @@
friend QTextStream &operator<<( QTextStream &stream, const
MYODBCInsDataSource &rval );
protected:
- QString stringName; /*!< DSN (For example; odbc.ini section
name) */
- QHash<QString,QString> hashAttributes; /*!< DSN attributes (for example;
DRIVER, UID, PWD, DATABASE,... */
+ QString stringName; /*!< DSN (For example; odbc.ini section
name) */
+ QHash<QString,QString> hashAttributes; /*!< DSN attributes (for example;
DRIVER, UID, PWD, DATABASE,... does NOT include DSN */
DATASOURCE_MODE nMode;
DATASOURCE_SCOPE nScope;
Modified: trunk/MYODBCSetup/MYODBCSetupLib/ConfigDSNW.cpp
===================================================================
--- trunk/MYODBCSetup/MYODBCSetupLib/ConfigDSNW.cpp 2006-06-22 19:33:17 UTC (rev 361)
+++ trunk/MYODBCSetup/MYODBCSetupLib/ConfigDSNW.cpp 2006-06-22 21:30:26 UTC (rev 362)
@@ -77,22 +77,20 @@
if ( MYODBCSetupDataSourceConfig( hWnd, &datasource ) )
{
if ( !datasource.doWrite() )
- {
- MYODBCIns::setError( "Failed to add DSN." );
MYODBCDbgReturn3( "%d", false );
- }
}
break;
case ODBC_CONFIG_DSN:
datasource.setMode( MYODBCInsDataSource::DATASOURCE_MODE_DSN_EDIT );
+
+ if ( !datasource.doRead() )
+ MYODBCDbgReturn3( "%d", false );
+
if ( MYODBCSetupDataSourceConfig( hWnd, &datasource ) )
{
if ( !datasource.doWrite() )
- {
- MYODBCIns::setError( "Failed to update DSN." );
MYODBCDbgReturn3( "%d", false );
- }
}
break;
Modified: trunk/MYODBCSetup/MYODBCSetupLib/MYODBCSetupDataSourceDialog.cpp
===================================================================
--- trunk/MYODBCSetup/MYODBCSetupLib/MYODBCSetupDataSourceDialog.cpp 2006-06-22 19:33:17
UTC (rev 361)
+++ trunk/MYODBCSetup/MYODBCSetupLib/MYODBCSetupDataSourceDialog.cpp 2006-06-22 21:30:26
UTC (rev 362)
@@ -83,20 +83,12 @@
if ( pDataSource->getMode() != MYODBCInsDataSource::DATASOURCE_MODE_DSN_VIEW )
{
- pDataSource->doClear();
-
- if ( !ptab1->getDataSourceName().isEmpty() )
- pDataSource->setName( ptab1->getDataSourceName() );
- if ( !ptab1->getDescription().isEmpty() )
- pDataSource->setDESCRIPTION( ptab1->getDescription() );
- if ( !ptab1->getServer().isEmpty() )
- pDataSource->setSERVER( ptab1->getServer() );
- if ( !ptab1->getUser().isEmpty() )
- pDataSource->setUID( ptab1->getUser() );
- if ( !ptab1->getPassword().isEmpty() )
- pDataSource->setPWD( ptab1->getPassword() );
- if ( !ptab1->getDatabase().isEmpty() )
- pDataSource->setDATABASE( ptab1->getDatabase() );
+ pDataSource->setName( ptab1->getDataSourceName() );
+ pDataSource->setDESCRIPTION( ptab1->getDescription() );
+ pDataSource->setSERVER( ptab1->getServer() );
+ pDataSource->setUID( ptab1->getUser() );
+ pDataSource->setPWD( ptab1->getPassword() );
+ pDataSource->setDATABASE( ptab1->getDatabase() );
}
// exit
| Thread |
|---|
| • Connector/ODBC 5 commit: r362 - in trunk: MYODBCIns/MYODBCInsLib MYODBCIns/MYODBCInsTest MYODBCIns/include MYODBCSetup/MYODBCSetupLib | pharvey | 22 Jun |