Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » MobiLink - Server Administration » Writing Synchronization Scripts in .NET » MobiLink server API for .NET reference

MobiLink server API for .NET reference Next Page

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:

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 );
// Execute update
DBRowReader rset = cstmt.ExecuteNonQuery();
cstmt.Close();

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