1.1.1

Table Of Contents
{
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 named parameters
cmd = new SQLFCommand("insert into t1 values (:ID, :ADDR)", conn);
cmd.Prepare();
DbParameter prm;
for (int i = 0; i < 1000; i++) {
// first the parameter for ID
cmd.Parameters.Clear();
prm = cmd.CreateParameter();
prm.ParameterName = "ID";
prm.DbType = DbType.Int32;
prm.Value = i;
cmd.Parameters.Add(prm);
// then the parameter for ADDR
prm = cmd.CreateParameter();
prm.ParameterName = "ADDR";
prm.DbType = DbType.String;
prm.Value = "addr" + i;
cmd.Parameters.Add(prm);
cmd.ExecuteNonQuery();
}
// drop the table
cmd = new SQLFCommand("drop table t1", conn);
cmd.ExecuteNonQuery();
conn.Close();
}
Example: Using both positional and named parameters
// Open a new connection to the network server running on localhost:1527
string host = "localhost";
int port = 1527;
string connectionStr = string.Format("server={0}:{1}", host, port);
using (SQLFClientConnection conn = new SQLFClientConnection(connectionStr))
{
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 a mix of named and positional parameters
cmd = new SQLFCommand("insert into t1 values (:ID, ?)", conn);
cmd.Prepare();
DbParameter prm;
for (int i = 0; i < 1000; i++) {
// first the parameter for ID
cmd.Parameters.Clear();
prm = cmd.CreateParameter();
prm.ParameterName = "ID";
vFabric SQLFire User's Guide694
vFabric SQLFire Reference