Contents Index Data manipulation: INSERT, UPDATE and DELETE Navigating through dynamic SQL result sets

UltraLite.NET User's Guide
  Understanding UltraLite Development
    Accessing and manipulating data with dynamic SQL

Data retrieval: SELECT


Use the SELECT statement to retrieve information from the database.

To execute a SELECT query using ExecuteQuery:

  1. Create a new prepared statement and result set.

    PreparedStatement prepStmt;
  2. Assign a prepared statement to your newly created PreparedStatement object.

    prepStmt = conn.PrepareStatement(
       "SELECT MyColumn FROM MyTable");
  3. Execute the statement.

    In the following code, the result of the SELECT query contain a string, which is output to a command prompt.

    ResultSet customerNames = prepStmt.ExecuteQuery();
    customerNames.MoveBeforeFirst();
    while( customerNames.MoveNext() ) {
       for ( int i = 1; 
             i <= customerNames.Schema.GetColumnCount(); 
             i++ ) {
            System.Console.Write(
            customerNames.GetString( i ) + " "
            );
            System.Console.WriteLine();
      }
    }

Contents Index Data manipulation: INSERT, UPDATE and DELETE Navigating through dynamic SQL result sets