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
DBParameterCollection Parameters property