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.
To execute a SELECT statement
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(); } |
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |