1.0

Table Of Contents
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();
SQLFDataReader reader = command.ExecuteReader();
StringBuilder row = new StringBuilder();
while (reader.Read())
{
for (int i = 0; i < reader.FieldCount; i++)
row.AppendFormat("{0}, ", reader.GetString(i));
Console.WriteLine(row.ToString());
}
}
121
Developing ADO.NET Client Applications