home *** CD-ROM | disk | FTP | other *** search
- Save Format v1.3
- @begin ClassFile "SQLAnyUtil"
- Exported 0;
-
- @begin UserFunction "SQLAnyUtil()"
- GencodeSrcLine 15;
- FunctionName "SQLAnyUtil::SQLAnyUtil()";
- @end;
-
- @begin UserFunction "Prototype for SQLAnyUtil()"
- Private 1;
- GencodeSrcLine 22;
- FunctionName "SQLAnyUtil::Prototype for SQLAnyUtil()";
- @end;
-
- @begin UserFunction "~SQLAnyUtil()"
- GencodeSrcLine 19;
- FunctionName "SQLAnyUtil::~SQLAnyUtil()";
- @end;
-
- @begin UserFunction "Prototype for ~SQLAnyUtil()"
- Private 1;
- GencodeSrcLine 24;
- FunctionName "SQLAnyUtil::Prototype for ~SQLAnyUtil()";
- @end;
-
- @begin UserFunction "DataSourceExists( WString const & source )"
- GencodeSrcLine 23;
- FunctionName "SQLAnyUtil::DataSourceExists( WString const & source )";
- @end;
-
- @begin UserFunction "Prototype for DataSourceExists( WString const & source )"
- Private 1;
- GencodeSrcLine 26;
- FunctionName "SQLAnyUtil::Prototype for DataSourceExists( WString const & source )";
- @end;
-
- @begin UserFunction "DataSourceAdd( WString const & name, WString const & dbfile )"
- GencodeSrcLine 52;
- FunctionName "SQLAnyUtil::DataSourceAdd( WString const & name, WString const & dbfile )";
- @end;
-
- @begin UserFunction "Prototype for DataSourceAdd( WString const & name, WString const & dbfile )"
- Private 1;
- GencodeSrcLine 28;
- FunctionName "SQLAnyUtil::Prototype for DataSourceAdd( WString const & name, WString const & dbfile )";
- @end;
-
- @begin UserFunction "GetSampleDBPath( void )"
- GencodeSrcLine 109;
- FunctionName "SQLAnyUtil::GetSampleDBPath( void )";
- @end;
-
- @begin UserFunction "Prototype for GetSampleDBPath( void )"
- Private 1;
- GencodeSrcLine 30;
- FunctionName "SQLAnyUtil::Prototype for GetSampleDBPath( void )";
- @end;
-
- @begin UserFunction "ErrorMessage( WForm * parent, WString const & title, WQuery * query )"
- GencodeSrcLine 126;
- FunctionName "SQLAnyUtil::ErrorMessage( WForm * parent, WString const & title, WQuery * query )";
- @end;
-
- @begin UserFunction "Prototype for ErrorMessage( WForm * parent, WString const & title, WQuery * query )"
- Private 1;
- GencodeSrcLine 32;
- FunctionName "SQLAnyUtil::Prototype for ErrorMessage( WForm * parent, WString const & title, WQuery * query )";
- @end;
-
- @begin HPPPrefixBlock
- @begin-code HPPPrefix
-
- // Declarations added here will be included at the top of the .HPP file
-
- @end-code;
- GencodeSrcLine 11;
- @end;
-
- @begin CPPPrefixBlock
- @begin-code CPPPrefix
-
- // Code added here will be included at the top of the .CPP file
-
- // Include definitions for resources.
- #include "WRes.h"
-
- @end-code;
- GencodeSrcLine 11;
- @end;
-
- @begin ClassContentsBlock
- @begin-code ClassContents
-
- public:
- // add your public instance data here
- private:
- // add your private instance data here
- protected:
- // add your protected instance data here
-
- @end-code;
- GencodeSrcLine 16;
- @end;
-
- @begin-code GeneratedClassContents
-
-
- @end-code;
-
- @begin-code Code "SQLAnyUtil::SQLAnyUtil()"
-
- @@CLASSNAME@::@CLASSNAME@()
- {
-
- }
-
- @end-code;
-
- @begin-code Code "SQLAnyUtil::Prototype for SQLAnyUtil()"
-
- public:
- @@CLASSNAME@();
-
- @end-code;
-
- @begin-code Code "SQLAnyUtil::~SQLAnyUtil()"
-
- @@CLASSNAME@::~@CLASSNAME@()
- {
-
- }
-
- @end-code;
-
- @begin-code Code "SQLAnyUtil::Prototype for ~SQLAnyUtil()"
-
- public:
- ~@CLASSNAME@();
-
- @end-code;
-
- @begin-code Code "SQLAnyUtil::DataSourceExists( WString const & source )"
-
- // DataSourceExists
-
- // This functions checks to see if a specified data source
- // has been previously registered.
-
- static WBool @CLASSNAME@::DataSourceExists(
- WString const & source )
- {
- WRegistryKey registry;
- WString key;
- WBool ret = FALSE;
- WFilePath val;
-
- key = "Software\\ODBC\\ODBC.INI\\ODBC Data Sources";
- if( registry.Open( WRKeyCurrentUser, key ) ) {
- if( registry.HasValue( source, WRegDataString ) ) {
- key.Sprintf( "Software\\ODBC\\ODBC.INI\\%s", source.GetText() );
- if( registry.HasValue( "driver", WRegDataString ) ) {
- val = registry.GetStringValue( "driver" );
- if( val.Exists() ) {
- ret = TRUE;
- }
- }
- }
- registry.Close();
- }
- return( ret );
-
- }
-
- @end-code;
-
- @begin-code Code "SQLAnyUtil::Prototype for DataSourceExists( WString const & source )"
-
- public:
- static WBool DataSourceExists( WString const & source );
-
- @end-code;
-
- @begin-code Code "SQLAnyUtil::DataSourceAdd( WString const & name, WString const & dbfile )"
-
- static WBool @CLASSNAME@::DataSourceAdd(
- WString const & name,
- WString const & dbfile )
- {
- WRegistryKey dreg;
- WFilePath driver;
- WRegistryKey registry;
- WString key;
- WBool ret = FALSE;
-
- // Add the data source name to the list of data sources available
-
- key = "Software\\ODBC\\ODBC.INI\\ODBC Data Sources";
- if( registry.Open( WRKeyCurrentUser, key ) ) {
- registry.SetStringValue( name, "Sybase SQL Anywhere 5.0" );
- registry.Close();
- }
-
- // Create the detailed entry for the new data source <name>
- // AutoStop "yes"
- // Database File <dbfile>
- // Description <name>
- // Driver <driver registered for SQL Anywhere>
- // Start <dbeng50.exe in the same directory as the driver>
-
- key.Sprintf( "Software\\ODBC\\ODBC.INI\\%s", name.GetText() );
- if( registry.Create( WRKeyCurrentUser, key ) ) {
-
- registry.SetStringValue( "AutoStop", "yes" );
- registry.SetStringValue( "DatabaseFile", dbfile );
- registry.SetStringValue( "Description", name );
-
- // Fetch the driver info from the SQL Anywhere entry
-
- driver.Clear(); // Null
- key.SetText( "Software\\ODBC\\ODBCINST.INI\\Sybase SQL Anywhere 5.0" );
- if( dreg.Open( WRKeyLocalMachine, key ) ) {
- driver = dreg.GetStringValue( "Driver" );
- dreg.Close();
- }
-
- if( !driver.GetNull() ) {
-
- // Use the driver path to set the Driver values.
- registry.SetStringValue( "Driver", driver.GetText() );
-
- // Replace the driver file name with the engine file name for the Start value.
- driver.MakePath( NULL, NULL, "dbeng50", "exe", _WFILEPATH_ALL );
- registry.SetStringValue( "Start", driver );
-
- ret = TRUE;
- }
-
- registry.Close();
- }
- return( ret );
- }
-
- @end-code;
-
- @begin-code Code "SQLAnyUtil::Prototype for DataSourceAdd( WString const & name, WString const & dbfile )"
-
- public:
- static WBool DataSourceAdd( WString const & name, WString const & dbfile );
-
- @end-code;
-
- @begin-code Code "SQLAnyUtil::GetSampleDBPath( void )"
-
- // GetSampleDBPath
-
- // Return the path to the standard SQL Anywhere sample database
-
- static WString @CLASSNAME@::GetSampleDBPath( void )
- {
- WString dbfile;
- WRegistryKey registry;
- WString key;
-
- key = "Software\\ODBC\\ODBC.INI\\SQL Anywhere 5.0 Sample";
- if( registry.Open( WRKeyCurrentUser, key ) ) {
- dbfile = registry.GetStringValue( "DatabaseFile" );
- registry.Close();
- }
- return( dbfile );
- }
-
- @end-code;
-
- @begin-code Code "SQLAnyUtil::Prototype for GetSampleDBPath( void )"
-
- public:
- static WString GetSampleDBPath( void );
-
- @end-code;
-
- @begin-code Code "SQLAnyUtil::ErrorMessage( WForm * parent, WString const & title, WQuery * query )"
-
- static void @CLASSNAME@::ErrorMessage( WForm * parent, WString const & title, WQuery * query )
- {
- WDataErrorArray errList;
-
- errList = query->GetErrorList();
- for( WInt i = 0; i < errList.GetCount(); i++ ) {
- WLong errCode = errList[i].GetErrorCode();
- WString errMsg = errList[i].GetErrorMessage();
- WLong funcCode = errList[i].GetFunctionCode();
- WLong natCode = errList[i].GetNativeCode();
- WString state = errList[i].GetSQLState();
-
- // View the debug log to see these messages
- WDBG(( "*** Update Error ***" ));
- WDBG(( "Error code: %ld", errCode ));
- WDBG(( "Message: '%s'", errMsg.GetText() ));
- WDBG(( "Function code: %ld", funcCode ));
- WDBG(( "Native code: %ld", natCode ));
- WDBG(( "SQL State: '%s'", state.GetText() ));
-
- // Use the form title for the error message
- WMessageBox::Messagef(
- parent, WMBLevelError, WMBButtonOk, title,
- "%s", errMsg.GetText() );
- }
- }
-
- @end-code;
-
- @begin-code Code "SQLAnyUtil::Prototype for ErrorMessage( WForm * parent, WString const & title, WQuery * query )"
-
- public:
- static void ErrorMessage( WForm * parent, WString const & title, WQuery * query );
-
- @end-code;
- @end;
-