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

@ -175,6 +175,9 @@ static int query_get_items(void* jolly, int argc, char** values, char** columns)
TRecnotype TODBC_recordset::items() const TRecnotype TODBC_recordset::items() const
{ {
if (_items == 0) if (_items == 0)
{
XVT_ODBC oc = connection();
if (oc != NULL)
{ {
TString sql; parsed_text(sql); TString sql; parsed_text(sql);
TPerformance_profiler prof("ODBC count"); TPerformance_profiler prof("ODBC count");
@ -185,11 +188,12 @@ TRecnotype TODBC_recordset::items() const
TODBC_recordset* myself = (TODBC_recordset*)this; TODBC_recordset* myself = (TODBC_recordset*)this;
myself->_page.destroy(); myself->_page.destroy();
myself->_cursor_pos = 0; myself->_cursor_pos = 0;
i = xvt_odbc_execute(connection(), sql, query_get_items, (void*)this); i = xvt_odbc_execute(oc, sql, query_get_items, (void*)this);
myself->_columns_loaded = true; myself->_columns_loaded = true;
} }
else else
i = xvt_odbc_execute(connection(), sql, NULL, NULL); i = xvt_odbc_execute(oc, sql, NULL, NULL);
}
} }
return _items; return _items;
} }
@ -197,14 +201,18 @@ TRecnotype TODBC_recordset::items() const
unsigned int TODBC_recordset::columns() const unsigned int TODBC_recordset::columns() const
{ {
if (!_columns_loaded && _column.items() == 0) if (!_columns_loaded && _column.items() == 0)
{
XVT_ODBC oc = connection();
if (oc != NULL)
{ {
TODBC_recordset* myself = (TODBC_recordset*)this; TODBC_recordset* myself = (TODBC_recordset*)this;
TString sql; parsed_text(sql); TString sql; parsed_text(sql);
TPerformance_profiler prof("ODBC info"); TPerformance_profiler prof("ODBC info");
myself->_cursor_pos = 0; myself->_cursor_pos = 0;
xvt_odbc_execute(connection(), sql, query_get_columns, (void*)this); xvt_odbc_execute(oc, sql, query_get_columns, (void*)this);
myself->_columns_loaded = true; 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)
{ {
long err = -1;
XVT_ODBC oc = connection();
if (oc != NULL)
{
TPerformance_profiler prof("ODBC command"); TPerformance_profiler prof("ODBC command");
set(sql); set(sql);
TString cmd; parsed_text(cmd); TString cmd; parsed_text(cmd);
return xvt_odbc_execute(connection(), cmd, NULL, NULL); err = xvt_odbc_execute(oc, cmd, NULL, NULL);
}
return err;
} }
TRecnotype TODBC_recordset::current_row() const TRecnotype TODBC_recordset::current_row() const