1.1

Table Of Contents
The MSDN documentation for IDataReader and DbDataReader provides details about other API methods and
usage.
Example
// Open a new connection to the network server running on
localhost:1527
string host = "localhost";
int port = 1527;
string connStr = string.Format("server={0}:{1}", host, port);
// use the SQLFire specific class for connection creation
using (SQLFClientConnection conn = new
SQLFClientConnection(connStr)) {
conn.Open();
// create a table
SQLFCommand cmd = new SQLFCommand(
"create table t1 (id int primary key, addr
varchar(20))", conn);
cmd.ExecuteNonQuery();
// insert into the table using positional parameters
cmd = new SQLFCommand("insert into t1 (id, addr) values (?,
?)", conn);
cmd.Prepare();
for (int i = 1; i <= 1000; i++) {
cmd.Parameters.Clear();
cmd.Parameters.Add(i);
cmd.Parameters.Add("addr" + i);
cmd.ExecuteNonQuery();
}
// now query the table using a DataReader
cmd.Parameters.Clear();
cmd.CommandText = "select * from t1";
SQLFDataReader reader = cmd.ExecuteReader();
int[] ids = new int[1000];
int numResults = 0;
while (reader.Read()) {
int id = reader.GetInt32(0);
string addr = reader.GetString(1);
Console.WriteLine("Read ID=" + id + ", addr=" + addr);
if (ids[id - 1] != 0) {
throw new Exception("Duplicate value for ID=" + id);
}
ids[id - 1] = id;
numResults++;
}
reader.Close();
if (numResults != 1000) {
throw new Exception("unexpected number of results " +
numResults);
}
// drop the table
cmd = new SQLFCommand("drop table t1", conn);
cmd.ExecuteNonQuery();
vFabric SQLFire User's Guide680
vFabric SQLFire Reference