1.1.1

Table Of Contents
is easier to implement, it is useful only in scenarios where an application has a xed set of threads, or long-lived
threads that operate against a SQLFire system.
Executing SQL Commands
To execute a SQL command, create a SQLFCommand from the SQLFire connection and supply the text of a
SQL command.
For example:
string sqlfHost = "localhost";
int sqlfPort = 1527;
string connectionStr = string.Format(@"server={0}:{1}", sqlfHost, sqlfPort);
SQLFClientConnection connection = null;
try
{
connection = new SQLFClientConnection(connectionStr);
SQLFCommand command = connection.CreateCommand();
command.CommandType = CommandType.Text;
command.CommandText = "SELECT COUNT(*) FROM product";
connection.Open();
int prodCount = Convert.ToInt32(command.ExecuteScalar());
}
catch (Exception e)
{
///
/// Log or re-throw exception
///
}
finally
{
connection.Close();
}
Working with Result Sets
SQLFDataReader helps you work with multiple rows that are returned from a SQL statement.
The following example queries all rows from a sample table and stores the results in a SQLFDataReader object.
The application then accesses and displays each row in the result set.
string sqlfHost = "localhost";
int sqlfPort = 1527;
string connectionStr = string.Format(@"server={0}:{1}", sqlfHost, sqlfPort);
SQLFClientConnection connection = null;
try
{
connection = new SQLFClientConnection(connectionStr);
SQLFCommand command = connection.CreateCommand();
command.CommandType = CommandType.Text;
command.CommandText = "SELECT * FROM product";
connection.Open();
135
Developing ADO.NET Client Applications