DbLib: Prevent uncaught exception creating statement
Defer telling the statement about the connection until the try block, because otherwise it can connect immediately and potentially throw an exception if the connection fails.
This commit is contained in:
parent
6482a322da
commit
ddd7c35586
|
@ -390,15 +390,14 @@ bool DATABASE_CONNECTION::SelectOne( const std::string& aTable,
|
|||
columnsFor( tableName ),
|
||||
m_quoteChar, tableName, m_quoteChar,
|
||||
m_quoteChar, columnName, m_quoteChar );
|
||||
|
||||
nanodbc::statement statement( *m_conn );
|
||||
nanodbc::string query = fromUTF8( queryStr );
|
||||
|
||||
PROF_TIMER timer;
|
||||
nanodbc::statement statement;
|
||||
|
||||
try
|
||||
{
|
||||
statement.prepare( query );
|
||||
statement.prepare( *m_conn, query );
|
||||
statement.bind( 0, aWhere.second.c_str() );
|
||||
}
|
||||
catch( nanodbc::database_error& e )
|
||||
|
|
Loading…
Reference in New Issue