|
|
Sponsor |
bk commit - MyODBC 3.51 (1.352): msg#00021db.mysql.odbc
Below is the list of changes that have just been commited into a local MyODBC 3.51 repository of 'pharvey'. When 'pharvey' does a push, they will be propogaged to the main repository and within 2 hours after the push into the public repository. For more information on how to access the public repository see: http://www.mysql.com/products/myodbc/faq_2.html#Development_source You can also browse the changes from public repository: Complete repository: http://mysql.bkbits.net:8080/myodbc3/ This changeset : http://mysql.bkbits.net:8080/myodbc3/cset@xxxxx ChangeSet 1.352 04/08/06 22:00:53 peterh@xxxxxxxxx +5 -0 adding MYODBCConfig (linux) setup/MYODBCSetupDataSourceDialog.h 1.3 04/08/06 22:00:53 peterh@xxxxxxxxx +9 -2 adding MYODBCConfig (linux) setup/MYODBCSetupDataSourceDialog.cpp 1.3 04/08/06 22:00:53 peterh@xxxxxxxxx +196 -47 adding MYODBCConfig (linux) myodbcinst/myodbcinst.c 1.14 04/08/06 22:00:53 peterh@xxxxxxxxx +1 -1 adding MYODBCConfig (linux) MYODBCConfig/MYODBCConfig.pro 1.1 04/08/06 22:00:13 peterh@xxxxxxxxx +45 -0 MYODBCConfig/MYODBCConfig.pro 1.0 04/08/06 22:00:13 peterh@xxxxxxxxx +0 -0 BitKeeper file /home/pharvey/SandBox/MySQL/myodbc-3.51/MYODBCConfig/MYODBCConfig.pro MYODBCConfig/main.cpp 1.1 04/08/06 22:00:06 peterh@xxxxxxxxx +26 -0 MYODBCConfig/main.cpp 1.0 04/08/06 22:00:06 peterh@xxxxxxxxx +0 -0 BitKeeper file /home/pharvey/SandBox/MySQL/myodbc-3.51/MYODBCConfig/main.cpp # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: peterh # Host: peter.peterharvey.org # Root: /home/pharvey/SandBox/MySQL/myodbc-3.51 --- New file --- +++ MYODBCConfig/MYODBCConfig.pro 04/08/06 22:00:13 # ######################################################### # COMMON # ######################################################### TEMPLATE = app DESTDIR = ./ OBJECTS_DIR = .tmp MOC_DIR = .tmp UI_DIR = .tmp LANGUAGE = C++ CPP_ALWAYS_CREATE_SOURCE = TRUE CONFIG += qt windows warn_on release INCLUDEPATH += ../setup DEFINES += VERSION="\"1.0.0\"" # ######################################################### # WIN32 # ######################################################### win32:TARGET = MYODBCConfig win32:DEFINES -= UNICODE win32:LIBS += odbc32.lib odbccp32.lib # win32:RC_FILE += MYODBCConfig.rc # ######################################################### # UNIX # ######################################################### unix:TARGET = MYODBCConfig unix:LIBS += -L/usr/local/lib -lodbc -lodbcinst -lmyodbc3S # ######################################################### # OSX # ######################################################### mac:LIBS += -lodbc -lodbcinst -lmyodbc3S mac:LIBS += -framework Carbon -framework QuickTime -lz -framework OpenGL -framework AGL -lz mac:RC_FILE = MYODBCConfig.icns # ######################################################### # FILES # ######################################################### HEADERS += \ ../setup/MYODBCSetup.h \ ../setup/MYODBCSetupDataSourceDialog.h SOURCES += \ main.cpp --- New file --- +++ MYODBCConfig/main.cpp 04/08/06 22:00:06 #include "MYODBCSetupDataSourceDialog.h" #include <qapplication.h> #include <qstring.h> /*! Default args (in case missing on command-line). */ char *pszDriver = "MySQL ODBC 3.51 Driver"; char *pszDataSourceName = "myodbc"; int main( int argc, char **argv ) { QApplication app( argc, argv ); MYODBCSetupDataSourceDialog *pmainwidget = new MYODBCSetupDataSourceDialog( NULL, ODBC_CONFIG_DSN, pszDriver, pszDataSourceName ); app.setMainWidget( pmainwidget ); pmainwidget->show(); app.connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) ); int nResult = app.exec(); delete pmainwidget; return nResult; } --- 1.13/myodbcinst/myodbcinst.c Fri Aug 6 02:38:56 2004 +++ 1.14/myodbcinst/myodbcinst.c Fri Aug 6 22:00:53 2004 @@ -64,7 +64,7 @@ "Peter Harvey\n"; char *szDriverName = "MySQL ODBC 3.51 Driver"; -char *szSampleDataSource = "DSN=myodbc\0Server=localhost\0Port=\0User=\0Password=\0Database=test\0Option=3\0Socket=\0Stmt=\0\0"; +char *szSampleDataSource = "DSN=myodbc\0SERVER=localhost\0USER=\0PASSWORD=\0DATABASE=test\0PORT=\0OPTION=3\0SOCKET=\0STMT=\0\0"; char cAction = '_'; int bGUI = 0; --- 1.2/setup/MYODBCSetupDataSourceDialog.cpp Fri Aug 6 02:38:56 2004 +++ 1.3/setup/MYODBCSetupDataSourceDialog.cpp Fri Aug 6 22:00:53 2004 @@ -2,47 +2,110 @@ #include "MySQLSide.xpm" +#include <qstring.h> + MYODBCSetupDataSourceDialog::MYODBCSetupDataSourceDialog( QWidget *pwidgetParent, WORD nRequest, LPCSTR pszDriver, MYODBC_NAMEVALUE **aNameValues ) - : QTabDialog( pwidgetParent ) + : QTabDialog( pwidgetParent, "MYODBCSetupDataSourceDialog" ) { - this->nRequest = nRequest; - this->pszDriver = pszDriver; - this->aNameValues = aNameValues; + this->nRequest = nRequest; + this->pszDriver = pszDriver; + this->pszDataSourceName = NULL; + this->aNameValues = aNameValues; // do some lookups nDataSourceName = MYODBCSetupGetAttributeIndex( aNameValues, "DSN" ); - nDescription = MYODBCSetupGetAttributeIndex( aNameValues, "DESCRIPTION" );; - nServer = MYODBCSetupGetAttributeIndex( aNameValues, "SERVER" );; - nUser = MYODBCSetupGetAttributeIndex( aNameValues, "USER" );; - nPassword = MYODBCSetupGetAttributeIndex( aNameValues, "PASSWORD" );; - nDatabase = MYODBCSetupGetAttributeIndex( aNameValues, "DATABASE" );; - nPort = MYODBCSetupGetAttributeIndex( aNameValues, "PORT" );; - nStmt = MYODBCSetupGetAttributeIndex( aNameValues, "STMT" );; - nSocket = MYODBCSetupGetAttributeIndex( aNameValues, "SOCKET" );; - nOption = MYODBCSetupGetAttributeIndex( aNameValues, "OPTION" );; + nDescription = MYODBCSetupGetAttributeIndex( aNameValues, "DESCRIPTION" ); + nServer = MYODBCSetupGetAttributeIndex( aNameValues, "SERVER" ); + nUser = MYODBCSetupGetAttributeIndex( aNameValues, "USER" ); + nPassword = MYODBCSetupGetAttributeIndex( aNameValues, "PASSWORD" ); + nDatabase = MYODBCSetupGetAttributeIndex( aNameValues, "DATABASE" ); + nPort = MYODBCSetupGetAttributeIndex( aNameValues, "PORT" ); + nStmt = MYODBCSetupGetAttributeIndex( aNameValues, "STMT" ); + nSocket = MYODBCSetupGetAttributeIndex( aNameValues, "SOCKET" ); + nOption = MYODBCSetupGetAttributeIndex( aNameValues, "OPTION" ); - setupTab1(); + if ( nDataSourceName >= 0 ) + this->pszDataSourceName = aNameValues[nDataSourceName]->pszValue; - QString stringRequest = "?"; - if ( nRequest == ODBC_ADD_DSN ) - { - stringRequest = "ADD"; - } - else if ( nRequest == ODBC_CONFIG_DSN ) - { - stringRequest = "EDIT"; - } + doInit(); +} - if ( pszDriver ) - setCaption( QString( pszDriver ) + " - data source configuration - " + stringRequest ); - else - setCaption( "MyODBC - data source configuration - " + stringRequest ); +MYODBCSetupDataSourceDialog::MYODBCSetupDataSourceDialog( QWidget *pwidgetParent, WORD nRequest, LPCSTR pszDriver, LPCSTR pszDataSourceName ) + : QTabDialog( pwidgetParent ) +{ + this->nRequest = nRequest; + this->pszDriver = pszDriver; + this->pszDataSourceName = pszDataSourceName; + this->aNameValues = NULL; - setCancelButton(); - setHelpButton(); + // do some lookups + nDataSourceName = -1; + nDescription = -1; + nServer = -1; + nUser = -1; + nPassword = -1; + nDatabase = -1; + nPort = -1; + nStmt = -1; + nSocket = -1; + nOption = -1; - connect( this, SIGNAL( helpButtonPressed() ), this, SLOT( slotHelp() ) ); - connect( this, SIGNAL( applyButtonPressed() ), this, SLOT( slotApply() ) ); + doInit(); +} + +void MYODBCSetupDataSourceDialog::slotTest() +{ + SQLHENV hEnv; + SQLHDBC hDbc; + SQLRETURN nReturn; + QString stringConnectIn; + + /* build connect string in */ + stringConnectIn = "DRIVER={" + QString( pszDriver ) + "}"; + stringConnectIn += ";UID=" + plineeditUser->text(); + stringConnectIn += ";PWD=" + plineeditPassword->text(); + stringConnectIn += ";SERVER=" + plineeditServer->text(); + if ( !pcomboboxDatabase->lineEdit()->text().isEmpty() ) + stringConnectIn += ";DATABASE=" + pcomboboxDatabase->lineEdit()->text(); + if ( !plineeditPort->text().isEmpty() ) + stringConnectIn += ";PORT=" + plineeditPort->text(); + if ( !plineeditSocket->text().isEmpty() ) + stringConnectIn += ";SOCKET=" + plineeditSocket->text(); + if ( !plineeditOptions->text().isEmpty() ) + stringConnectIn += ";OPTION=" + plineeditOptions->text(); + if ( !plineeditStmt->text().isEmpty() ) + stringConnectIn += ";STMT=" + plineeditStmt->text(); + + nReturn = SQLAllocHandle( SQL_HANDLE_ENV, NULL, &hEnv ); + if ( nReturn != SQL_SUCCESS ) + doShowDiagnostics( nReturn, SQL_HANDLE_ENV, NULL ); + if ( !SQL_SUCCEEDED(nReturn)) + return; + + nReturn = SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, 0 ); + if ( nReturn != SQL_SUCCESS ) + doShowDiagnostics( nReturn, SQL_HANDLE_ENV, NULL ); + if ( !SQL_SUCCEEDED(nReturn)) + goto slotTestExit1; + + nReturn = SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc ); + if ( nReturn != SQL_SUCCESS ) + doShowDiagnostics( nReturn, SQL_HANDLE_ENV, hEnv ); + if ( !SQL_SUCCEEDED(nReturn)) + goto slotTestExit1; + + nReturn = SQLDriverConnect( hDbc, NULL, (SQLCHAR*)stringConnectIn.latin1(), SQL_NTS, NULL, 0, NULL, SQL_DRIVER_NOPROMPT ); + if ( nReturn != SQL_SUCCESS ) + doShowDiagnostics( nReturn, SQL_HANDLE_DBC, hDbc ); + if ( !SQL_SUCCEEDED(nReturn)) + goto slotTestExit2; + + nReturn = SQLDisconnect( hDbc ); + +slotTestExit2: + nReturn = SQLFreeHandle( SQL_HANDLE_DBC, hDbc ); +slotTestExit1: + nReturn = SQLFreeHandle( SQL_HANDLE_ENV, hEnv ); } void MYODBCSetupDataSourceDialog::slotHelp() @@ -55,7 +118,7 @@ pprocess->addArgument( stringURL ); if ( !pprocess->start() ) { - QMessageBox::warning( 0, "MyODBC Help", "Failed to execute a browser.\n\nPlease visit\n" + stringURL, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); + QMessageBox::warning( this, "MyODBC Help", "Failed to execute a browser.\n\nPlease visit\n" + stringURL, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); delete pprocess; } #else @@ -65,7 +128,7 @@ pprocess->addArgument( stringURL ); if ( !pprocess->start() ) { - QMessageBox::warning( 0, "MyODBC Help", "Failed to execute a browser.\n\nPlease visit\n" + stringURL, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); + QMessageBox::warning( this, "MyODBC Help", "Failed to execute a browser.\n\nPlease visit\n" + stringURL, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); delete pprocess; } # else @@ -85,7 +148,7 @@ pprocess->addArgument( stringURL ); if ( !pprocess->start() ) { - QMessageBox::warning( 0, "MyODBC Help", "Failed to execute a browser.\n\nPlease visit\n" + stringURL, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); + QMessageBox::warning( this, "MyODBC Help", "Failed to execute a browser.\n\nPlease visit\n" + stringURL, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); delete pprocess; } } @@ -103,13 +166,36 @@ else if ( nRequest == ODBC_CONFIG_DSN ) { } + reject(); +} +void MYODBCSetupDataSourceDialog::doInit() +{ + doInitTab1(); - QMessageBox::warning( 0, "MyODBC Help", "Got here", QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); - reject(); + QString stringRequest = "?"; + if ( nRequest == ODBC_CONFIG_DSN ) + stringRequest = "EDIT"; + else + { + nRequest = ODBC_ADD_DSN; + stringRequest = "ADD"; + } + + if ( pszDriver ) + setCaption( QString( pszDriver ) + " - data source configuration - (" + QString( pszDataSourceName ) + ") " + stringRequest ); + else + setCaption( "MyODBC - data source configuration - (" + QString( pszDataSourceName ) + ") " + stringRequest ); + + setCancelButton(); + setHelpButton(); + + connect( ppushbuttonTest, SIGNAL( clicked() ), this, SLOT( slotTest() ) ); + connect( this, SIGNAL( helpButtonPressed() ), SLOT( slotHelp() ) ); + connect( this, SIGNAL( applyButtonPressed() ), SLOT( slotApply() ) ); } -void MYODBCSetupDataSourceDialog::setupTab1() +void MYODBCSetupDataSourceDialog::doInitTab1() { QWidget *pwidgetPage = new QWidget( this ); @@ -137,8 +223,8 @@ plineeditDataSourceName = new QLineEdit( pwidgetPage ); playoutFields->addWidget( plabel, nRow, nColLabel ); playoutFields->addWidget( plineeditDataSourceName, nRow, nColField ); - if ( nDataSourceName >= 0 ) - plineeditDataSourceName->setText( aNameValues[nDataSourceName]->pszValue ); + if ( pszDataSourceName ) + plineeditDataSourceName->setText( pszDataSourceName ); nRow++; plabel = new QLabel( "Description", pwidgetPage ); @@ -190,14 +276,6 @@ plineeditPort->setText( aNameValues[nPort]->pszValue ); nRow++; - plabel = new QLabel( "Stmt", pwidgetPage ); - plineeditStmt = new QLineEdit( pwidgetPage ); - playoutFields->addWidget( plabel, nRow, nColLabel ); - playoutFields->addWidget( plineeditStmt, nRow, nColField ); - if ( nStmt >= 0 ) - plineeditStmt->setText( aNameValues[nStmt]->pszValue ); - nRow++; - plabel = new QLabel( "Socket", pwidgetPage ); plineeditSocket = new QLineEdit( pwidgetPage ); playoutFields->addWidget( plabel, nRow, nColLabel ); @@ -214,6 +292,14 @@ plineeditOptions->setText( aNameValues[nOption]->pszValue ); nRow++; + plabel = new QLabel( "Stmt", pwidgetPage ); + plineeditStmt = new QLineEdit( pwidgetPage ); + playoutFields->addWidget( plabel, nRow, nColLabel ); + playoutFields->addWidget( plineeditStmt, nRow, nColField ); + if ( nStmt >= 0 ) + plineeditStmt->setText( aNameValues[nStmt]->pszValue ); + nRow++; + ppushbuttonTest = new QPushButton( "Test", pwidgetPage ); playoutFields->addWidget( ppushbuttonTest, nRow, nColField ); @@ -222,5 +308,68 @@ else addTab( pwidgetPage, "Data Source Name" ); } + + +void MYODBCSetupDataSourceDialog::doShowDiagnostics( SQLRETURN nReturn, SQLSMALLINT nHandleType, SQLHANDLE h ) +{ + BOOL bMessageShown = FALSE; + + if ( h ) + { + SQLSMALLINT nRec = 1; + SQLCHAR szSQLState[6]; + SQLINTEGER nNative; + SQLCHAR szMessage[SQL_MAX_MESSAGE_LENGTH]; + SQLSMALLINT nMessage; + + *szSQLState = '\0'; + *szMessage = '\0'; + + while ( SQL_SUCCEEDED( SQLGetDiagRec( nHandleType, + h, + nRec, + szSQLState, + &nNative, + szMessage, + SQL_MAX_MESSAGE_LENGTH, + &nMessage ) ) ) + { + szSQLState[5] = '\0'; + szMessage[SQL_MAX_MESSAGE_LENGTH - 1] = '\0'; + + if ( nReturn == SQL_ERROR ) + QMessageBox::critical( this, "MYODBCConfig", (char*)szMessage, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); + else if ( nReturn == SQL_SUCCESS_WITH_INFO ) + QMessageBox::warning( this, "MYODBCConfig", (char*)szMessage, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); + else + QMessageBox::information( this, "MYODBCConfig", (char*)szMessage, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); + + bMessageShown = TRUE; + nRec++; + + *szSQLState = '\0'; + *szMessage = '\0'; + } + } + + if ( !bMessageShown ) + { + switch ( nReturn ) + { + case SQL_ERROR: + QMessageBox::critical( this, "MYODBCConfig", "Request returned with SQL_ERROR. Sorry; no diagnostic information.", QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); + break; + case SQL_SUCCESS_WITH_INFO: + QMessageBox::warning( this, "MYODBCConfig", "Request return with SQL_SUCCESS_WITH_INFO. Sorry; no diagnostic information.", QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); + break; + case SQL_INVALID_HANDLE: + QMessageBox::critical( this, "MYODBCConfig", "Request returned with SQL_INVALID_HANDLE.", QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); + break; + default: + QMessageBox::information( this, "MYODBCConfig", "Request did not return with SQL_SUCCESS. Sorry; no diagnostic information.", QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); + } + } +} + --- 1.2/setup/MYODBCSetupDataSourceDialog.h Fri Aug 6 02:38:56 2004 +++ 1.3/setup/MYODBCSetupDataSourceDialog.h Fri Aug 6 22:00:53 2004 @@ -27,14 +27,17 @@ public: MYODBCSetupDataSourceDialog( QWidget *pwidgetParent, WORD nRequest, LPCSTR pszDriver, MYODBC_NAMEVALUE **aNameValues ); + MYODBCSetupDataSourceDialog( QWidget *pwidgetParent, WORD nRequest, LPCSTR pszDriver, LPCSTR pszDataSourceName ); -protected slots: +public slots: void slotHelp(); void slotApply(); + void slotTest(); protected: WORD nRequest; LPCSTR pszDriver; + LPCSTR pszDataSourceName; MYODBC_NAMEVALUE ** aNameValues; int nDataSourceName; int nDescription; @@ -61,10 +64,14 @@ QLineEdit * plineeditOptions; QPushButton *ppushbuttonTest; + void doInit(); + // Tab 2 // to do: break out options - void setupTab1(); + void doInitTab1(); + + void doShowDiagnostics( SQLRETURN nReturn, SQLSMALLINT nHandleType, SQLHANDLE h ); }; #endif -- MySQL ODBC Mailing List For list archives: http://lists.mysql.com/myodbc To unsubscribe: http://lists.mysql.com/myodbc?unsub=gcdmo-myodbc@xxxxxxxxxxx
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | bk commit - MyODBC 3.51 (1.351), peterh |
|---|---|
| Next by Date: | bk commit - MyODBC 3.51 (1.353), peterh |
| Previous by Thread: | bk commit - MyODBC 3.51 (1.351), peterh |
| Next by Thread: | bk commit - MyODBC 3.51 (1.353), peterh |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home | sitemap
| advertise | OSDir is
an inevitable website.
|