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