DBCommand interface

Syntax
interface DBCommand
Member of iAnywhere.MobiLink.Script
Remarks

Represents a SQL statement or database command. DBCommand can represent an update or query.

Example

For example, the following C# code uses the DBCommand interface to execute two queries:

DBCommand stmt = conn.CreateCommand(); 
stmt.CommandText = "SELECT t1a1, t1a2 FROM table1 "; 

DBRowReader rs = stmt.ExecuteReader();
printResultSet(rs);
rs.Close();

stmt.CommandText = "SELECT t2a1 FROM table2 "; 
rs = stmt.ExecuteReader();
printResultSet(rs);
rs.Close();
stmt.Close();

The following C# example uses DBCommand to execute an update with parameters:

public void prepare_for_download(
    DateTime last_download,
    String ml_username)
{
    DBCommand cstmt     = conn.CreateCommand(); 
    cstmt.CommandText   = "CALL myProc(?,?,?,?)"; 
    cstmt.Prepare(); 

    DBParameter param   = new DBParameter();
    param.DbType        = SQLType.SQL_CHAR;
    param.Value         = "10000";
    cstmt.Parameters.Add(param); 

    param               = new DBParameter();
    param.DbType        = SQLType.SQL_INTEGER;
    param.Value         = 20000;
    cstmt.Parameters.Add(param); 

    param               = new DBParameter();
    param.DbType        = SQLType.SQL_DECIMAL;
    param.Precision     = 5;
    param.Value         = new Decimal(30000);
    cstmt.Parameters.Add(param); 

    param               = new DBParameter();
    param.DbType        = SQLType.SQL_TIMESTAMP;
    param.Precision     = 19;
    param.Value         = last_download;
    cstmt.Parameters.Add(param); 

    // Execute update
    DBRowReader rset    = cstmt.ExecuteNonQuery();
    cstmt.Close();
}

Prepare method
ExecuteNonQuery method
ExecuteReader method
Close method
CommandText property
Parameters property