12. Understanding .NET Data Provider Connectivity : .NET Data Provider Classes : IngresParameter Class : IngresParameter Class Example
 
Share this page                  
IngresParameter Class Example
The following is an implementation of the IngresParameter class:
static string DemoParameterSSN(
    string connstring, int intNumber, string strSSN)
{
    IngresConnection conn = new IngresConnection(connstring);
 
 
    string strName = null;
 
    conn.Open();
 
    IngresCommand cmd = new IngresCommand(
        "select name from demo_personnel where number = ? and ssn = ?",
        conn);
 
    // add two parameters to the command's IngresParameterCollection
    cmd.Parameters.Add(new IngresParameter("Number", intNumber));
    IngresParameter parm =
        new IngresParameter("SSN", IngresType.VarChar);
    parm.Value = strSSN;
    cmd.Parameters.Add(parm);
 
    IngresDataReader reader = cmd.ExecuteReader();
 
    while (reader.Read())
    {
        if (reader.IsDBNull(0))
            break;
        strName = reader.GetString(0);
    }
 
    reader.Close();
    conn.Close();
 
    return strName;
}