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.
(cherry picked from commit ddd7c35586
)
Co-authored-by: Jon Evans <jon@craftyjon.com>
This commit is contained in:
parent
8184ed64e7
commit
6c41354da5
|
@ -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