More Unicode support added (though untested and still unfinished).

Changed code to demonstrate the new wxDbConnectInf class
ODBC environment handle now managed via the wxDbConnectInf class
Condensed the use of multiple wxDbConnectInf instances to one and got rid of the bogus EXTERNs of the wxDbConnectInf that were causing so many headaches and mismatched usages of them.
Other minor bug fixes - still have not foudn the reason for the crash on exit


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9277 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
George Tasker
2001-02-03 17:55:00 +00:00
parent 049977d042
commit eacf9d88f9
4 changed files with 33 additions and 37 deletions

View File

@@ -32,7 +32,7 @@
//----------------------------------------------------------------------------------------
// 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 */
@@ -79,7 +79,7 @@ char *GetExtendedDBErrorMsg(char *ErrFile, int ErrLine)
//----------------------------------------------------------------------------------------
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
@@ -90,7 +90,7 @@ BrowserDB::BrowserDB()
//----------------------------------------------------------------------------------------
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
//----------------------------------------------------------------------------------------
@@ -113,16 +113,12 @@ bool BrowserDB::OnStartDB(int Quiet)
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
//---------------------------------------------------------------------------------------
@@ -147,21 +143,22 @@ bool BrowserDB::OnStartDB(int Quiet)
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;
}
//--------------------------------------------------------------------------------------
@@ -175,7 +172,10 @@ bool BrowserDB::OnStartDB(int Quiet)
return TRUE;
}
else
{
DbConnectInf.FreeHenv();
return FALSE;
}
}
//----------------------------------------------------------------------------------------
@@ -187,13 +187,9 @@ bool BrowserDB::OnCloseDB(int Quiet)
{
// 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)
@@ -422,7 +418,7 @@ wxDbColInf* BrowserDB::OnGetColumns(char *tableName, int numCols, int Quiet)
}
//----------------------------------------------------------------------------------------
void BrowserDB::Zeiger_auf_NULL(int Art)
void BrowserDB::PointerToNULL(int Art)
{
if (Art == 1) // L<>schen
{

View File

@@ -14,7 +14,7 @@
//----------------------------------------------------------------------------------------
// Global structure for holding ODBC connection information
//----------------------------------------------------------------------------------------
extern wxDbConnectInf DbConnectInf;
//extern wxDbConnectInf DbConnectInf;
class MainDoc;
//----------------------------------------------------------------------------------------
@@ -61,7 +61,7 @@ public:
//---------------------------------------------------------------------------------------
BrowserDB();
~BrowserDB();
void Zeiger_auf_NULL(int Art);
void PointerToNULL(int Art);
bool Initialize(int Quiet);
//---------------------------------------------------------------------------------------
bool OnStartDB(int Quiet);

View File

@@ -33,7 +33,7 @@
//----------------------------------------------------------------------------------------
//-- 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
@@ -159,11 +159,12 @@ bool MainDoc::OnInitODBC()
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;
@@ -172,7 +173,7 @@ bool MainDoc::OnInitODBC()
// 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);
@@ -212,10 +213,9 @@ bool MainDoc::OnInitODBC()
(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;
//---------------------------------------------------------------------------------------

View File

@@ -22,7 +22,7 @@ public:
//----------------------------------------------------------------------------------------
// Global structure for holding ODBC connection information
extern wxDbConnectInf DbConnectInf;
//extern wxDbConnectInf DbConnectInf;
//----------------------------------------------------------------------------------------
extern wxConfigBase *p_ProgramCfg; // All Config and Path information