Patch level : 314

Files correlati     : tp0.exe
Ricompilazione Demo : [ ]
Commento            :
Migliorata gestione errori di connessione ad ODBC


git-svn-id: svn://10.65.10.50/trunk@18928 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2009-05-25 14:11:58 +00:00
parent bfe130f077
commit 1b33aaa5fb

View File

@ -176,20 +176,24 @@ TRecnotype TODBC_recordset::items() const
{
if (_items == 0)
{
TString sql; parsed_text(sql);
TPerformance_profiler prof("ODBC count");
TRecnotype& i = (TRecnotype&)_items;
if (!_columns_loaded)
XVT_ODBC oc = connection();
if (oc != NULL)
{
TODBC_recordset* myself = (TODBC_recordset*)this;
myself->_page.destroy();
myself->_cursor_pos = 0;
i = xvt_odbc_execute(connection(), sql, query_get_items, (void*)this);
myself->_columns_loaded = true;
TString sql; parsed_text(sql);
TPerformance_profiler prof("ODBC count");
TRecnotype& i = (TRecnotype&)_items;
if (!_columns_loaded)
{
TODBC_recordset* myself = (TODBC_recordset*)this;
myself->_page.destroy();
myself->_cursor_pos = 0;
i = xvt_odbc_execute(oc, sql, query_get_items, (void*)this);
myself->_columns_loaded = true;
}
else
i = xvt_odbc_execute(oc, sql, NULL, NULL);
}
else
i = xvt_odbc_execute(connection(), sql, NULL, NULL);
}
return _items;
}
@ -198,12 +202,16 @@ unsigned int TODBC_recordset::columns() const
{
if (!_columns_loaded && _column.items() == 0)
{
TODBC_recordset* myself = (TODBC_recordset*)this;
TString sql; parsed_text(sql);
TPerformance_profiler prof("ODBC info");
myself->_cursor_pos = 0;
xvt_odbc_execute(connection(), sql, query_get_columns, (void*)this);
myself->_columns_loaded = true;
XVT_ODBC oc = connection();
if (oc != NULL)
{
TODBC_recordset* myself = (TODBC_recordset*)this;
TString sql; parsed_text(sql);
TPerformance_profiler prof("ODBC info");
myself->_cursor_pos = 0;
xvt_odbc_execute(oc, sql, query_get_columns, (void*)this);
myself->_columns_loaded = true;
}
}
return _column.items();
}
@ -276,6 +284,11 @@ bool TODBC_recordset::move_to(TRecnotype n)
if (n < _first_row || n >= _first_row+_page.items())
{
XVT_ODBC oc = connection();
if (oc == NULL)
return false;
TString sql; parsed_text(sql);
if (tot > _pagesize && sql.find("LIMIT ") < 0)
{
@ -289,9 +302,11 @@ bool TODBC_recordset::move_to(TRecnotype n)
else
_first_row = n;
}
TPerformance_profiler prof("ODBC query");
_cursor_pos = 0;
xvt_odbc_execute(connection(), sql, query_get_rows, this);
xvt_odbc_execute(oc, sql, query_get_rows, this);
if (!_columns_loaded)
_columns_loaded = true; // Brutto posto ma necessario
}
@ -301,10 +316,18 @@ bool TODBC_recordset::move_to(TRecnotype n)
long TODBC_recordset::exec(const char* sql)
{
TPerformance_profiler prof("ODBC command");
set(sql);
TString cmd; parsed_text(cmd);
return xvt_odbc_execute(connection(), cmd, NULL, NULL);
long err = -1;
XVT_ODBC oc = connection();
if (oc != NULL)
{
TPerformance_profiler prof("ODBC command");
set(sql);
TString cmd; parsed_text(cmd);
err = xvt_odbc_execute(oc, cmd, NULL, NULL);
}
return err;
}
TRecnotype TODBC_recordset::current_row() const