//----------------------------------------------------------------------------------------
// Global structure for holding ODBC connection information
// - darf nur einmal im Projekte definiert werden ?? Extra Databasse Klasse ?
-wxDbConnectInf ConnectInf; // Für DBase
+wxDbConnectInf DbConnectInf; // Für DBase
//----------------------------------------------------------------------------------------
extern WXDLLEXPORT_DATA(wxDbList*) PtrBegDbList; /* from db.cpp, used in getting back error results from db connections */
//----------------------------------------------------------------------------------------
BrowserDB::BrowserDB()
{
- Zeiger_auf_NULL(0);
+ PointerToNULL(0);
ODBCSource = ""; // ODBC data source name (created with ODBC Administrator under Win95/NT)
UserName = ""; // database username - must already exist in the data source
Password = ""; // password database username
//----------------------------------------------------------------------------------------
BrowserDB::~BrowserDB()
{
- Zeiger_auf_NULL(1); // Clean up Tables and Databases (Commit, Close und delete)
+ PointerToNULL(1); // Clean up Tables and Databases (Commit, Close and delete)
} // BrowserDB destructor
//----------------------------------------------------------------------------------------
if (db_BrowserDB != NULL)
{
if (!Quiet)
- wxLogMessage(_("\n-I-> BrowserDB::OnStartDB() : DB is allready open."));
+ wxLogMessage(_("\n-I-> BrowserDB::OnStartDB() : DB is already open."));
return TRUE;
}
- // Initialize the ODBC Environment for Database Operations
- if (SQLAllocEnv(&ConnectInf.Henv) != SQL_SUCCESS)
- {
- if (!Quiet)
- wxLogMessage(_("\n-E-> BrowserDB::OnStartDB() : DB CONNECTION ERROR : A problem occured while trying to get a connection to the data source"));
- return FALSE;
- }
+
+ DbConnectInf.AllocHenv();
+
//---------------------------------------------------------------------------------------
// Connect to datasource
//---------------------------------------------------------------------------------------
if (OK)
{
//--------------------------------------------------------------------------------------
- ConnectInf.Dsn = ODBCSource; // ODBC data source name (created with ODBC Administrator under Win95/NT)
- ConnectInf.Uid = UserName; // database username - must already exist in the data source
- ConnectInf.AuthStr= Password; // password database username
- db_BrowserDB = wxDbGetConnection(&ConnectInf);
+ DbConnectInf.SetDsn(ODBCSource); // ODBC data source name (created with ODBC Administrator under Win95/NT)
+ DbConnectInf.SetUserID(UserName); // database username - must already exist in the data source
+ DbConnectInf.SetPassword(Password); // password database username
+ db_BrowserDB = wxDbGetConnection(&DbConnectInf);
// wxLogMessage(">>>%s<<<>>>%s<<<",UserName.c_str(),Password.c_str());
if (db_BrowserDB == NULL)
{
- ConnectInf.Dsn = "";
- ConnectInf.Uid = "";
- ConnectInf.AuthStr = "";
+ DbConnectInf.SetDsn(wxT(""));
+ DbConnectInf.SetUserID(wxT(""));
+ DbConnectInf.SetPassword(wxT(""));
if (!Quiet)
{
wxLogMessage(_("\n-E-> BrowserDB::OnConnectDataSource() DB CONNECTION ERROR : Unable to connect to the data source.\n\nCheck the name of your data source to verify it has been correctly entered/spelled.\n\nWith some databases, the user name and password must\nbe created with full rights to the table prior to making a connection\n(using tools provided by the database manufacturer)"));
wxLogMessage(_("-I-> BrowserDB::OnStartDB(%s) : End - Time needed : %ld ms"),ODBCSource.c_str(),sw.Time());
}
+ DbConnectInf.FreeHenv();
return FALSE;
}
//--------------------------------------------------------------------------------------
return TRUE;
}
else
+ {
+ DbConnectInf.FreeHenv();
return FALSE;
+ }
}
//----------------------------------------------------------------------------------------
{
// db_BrowserDB->Close();
wxDbFreeConnection(db_BrowserDB);
-/*
- // Free Environment Handle that ODBC uses
- if (SQLFreeEnv(&ConnectInf.Henv) != SQL_SUCCESS)
- {
- // Error freeing environment handle
- }
-*/
+
+ DbConnectInf.FreeHenv();
+
db_BrowserDB = NULL;
}
if (!Quiet)
}
//----------------------------------------------------------------------------------------
-void BrowserDB::Zeiger_auf_NULL(int Art)
+void BrowserDB::PointerToNULL(int Art)
{
if (Art == 1) // Löschen
{
//----------------------------------------------------------------------------------------
// Global structure for holding ODBC connection information
//----------------------------------------------------------------------------------------
-extern wxDbConnectInf DbConnectInf;
+//extern wxDbConnectInf DbConnectInf;
class MainDoc;
//----------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
BrowserDB();
~BrowserDB();
- void Zeiger_auf_NULL(int Art);
+ void PointerToNULL(int Art);
bool Initialize(int Quiet);
//---------------------------------------------------------------------------------------
bool OnStartDB(int Quiet);
//----------------------------------------------------------------------------------------
//-- Some Global Vars for all Files (extern in ?.h needed) -------------------------------
// Global structure for holding ODBC connection information
-wxDbConnectInf DbConnectInf;
+extern wxDbConnectInf DbConnectInf;
//----------------------------------------------------------------------------------------
wxConfigBase *p_ProgramCfg; // All Config and Path information
int i = 0;
//---------------------------------------------------------------------------------------
// Initialize the ODBC Environment for Database Operations
-
- if (SQLAllocEnv(&DbConnectInf.Henv) != SQL_SUCCESS)
+
+ if (!DbConnectInf.AllocHenv())
{
return FALSE;
}
+
//---------------------------------------------------------------------------------------
const char sep = 3; // separator character used in string between DSN ans DsDesc
wxStringList s_SortDSNList, s_SortDsDescList;
// The key will be removed after sorting
wxString KeyString;
//---------------------------------------------------------------------------------------
- while(wxDbGetDataSource(DbConnectInf.Henv, Dsn, sizeof(Dsn), DsDesc, sizeof(DsDesc)))
+ while(wxDbGetDataSource(DbConnectInf.GetHenv(), Dsn, sizeof(Dsn), DsDesc, sizeof(DsDesc)))
{
i_DSN++; // How many Dsn have we ?
KeyString.Printf("%s%c%s",Dsn, sep, DsDesc);
(db_Br+i)->pDoc = this;
(db_Br+i)->i_Which = i;
}
- if (SQLFreeEnv(DbConnectInf.Henv) != SQL_SUCCESS) // BJO20000125 / MJ10777.20000309 : no &
- {
- // Error freeing environment handle
- }
+
+ DbConnectInf.FreeHenv();
+
delete [] s_SortDSN;
delete [] s_SortDsDesc;
//---------------------------------------------------------------------------------------