Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SAP Sybase SQL Anywhere 16.0 » UltraLite - .NET Programming » UltraLite.NET application development » Data creation and modification using SQL statements


Retrieving data using SELECT

Execute a SELECT statement to retrieve information from an UltraLite database and handle the result set that is returned.


There are no prerequisites for this task.

  1. Declare a ULCommand object to holds the query.

    ULCommand cmd;
  2. Assign a statement to the object.

    cmd = conn.CreateCommand();
    cmd.CommandText = "SELECT MyColumn FROM MyTable";
  3. Execute the statement.

    Query results can be returned as one of several types of objects. In this example, a ULDataReader object is used.

    ULDataReader customerNames = cmd.ExecuteReader();
    int fc = customerNames.GetFieldCount();
    while( customerNames.MoveNext() ) {
      for ( int i = 0; i < fc; i++ ) {
        System.Console.Write(customerNames.GetString( i ) + " " );


The result of the SELECT statement contains a string, which is then output to the command prompt.