The SELECT statement allows you to retrieve information from the database. This section describes how to execute a SELECT statement and how to handle the result set it returns.
Declare a ULCommand object, which holds the query.
ULCommand cmd; |
Assign a statement to the object.
cmd = conn.CreateCommand(); cmd.Command = "SELECT MyColumn FROM MyTable"; |
Execute the statement.
Query results can be returned as one of several types of objects. In this example, a ULDataReader object is used. In the following code, the result of the SELECT statement contains a string, which is output to the command prompt.
ULDataReader customerNames = prepStmt.ExecuteReader(); int fc = customerNames.GetFieldCount(); while( customerNames.MoveNext() ) { for ( int i = 0; i < fc; i++ ) { System.Console.Write(customerNames.GetString( i ) + " " ); } System.Console.WriteLine(); } |
Discuss this page in DocCommentXchange.
|
Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |