UltraLite C++ User's Guide
Understanding UltraLite Development
Accessing and manipulating data with dynamic SQL
Use the SELECT statement to retrieve information from the database.
To execute a SELECT query using ExecuteQuery:
Create a new prepared statement and result set.
PreparedStatement * prepStmt;
Assign a prepared statement to your newly created PreparedStatement object.
ULValue sqltext( "SELECT MyColumn FROM MyTable" ); prepStmt = conn->PrepareStatement( sqltext );
Execute the statement.
In the following code, the result of the SELECT query contain a string, which is output to a command prompt.
#define MAX_NAME_LEN 100 ULValue mycol; ResultSet * rs = stmt->ExecuteQuery(); rs->BeforeFirst(); while( rs->Next() ){ char mycol[ MAX_NAME_LEN ]; val = rs->Get( 1 ); val.GetString( mycol, MAX_NAME_LEN ); printf( "mycol= %s\n", mycol ); }