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

SQL Anywhere 11.0.1 (Français) » MobiLink - Server Administration » MobiLink Server APIs » Writing synchronization scripts in .NET » MobiLink server API for .NET reference

 

DBParameter class

Syntax
class DBParameter
Member of iAnywhere.MobiLink.Script
Remarks

Represents a bound ODBC parameter.

DBParameter is required to execute commands with parameters. All parameters must be in place before the command is executed.

Example

For example, the following C# code uses DBCommand to execute an update with parameters:

public void handleUpload(UploadData ud) {
    UploadedTableData UTDAdmin = ud.GetUploadedTableByName("Admin");
    IDataReader       AdminIns = UTDAdmin.GetInserts();
    DBCommand         stmt1    = _conn.CreateCommand();
    DBParameter       p_id     = new DBParameter();
    DBParameter       p_data   = new DBParameter();

    stmt1.CommandText          = "INSERT INTO Admin(admin_id,data) VALUES (?,?)";
    p_id.DbType                = SQLType.SQL_BIGINT;
    stmt1.Parameters.Add(p_id);
    p_data.DbType              = SQLType.SQL_VARCHAR;
    p_data.Size                = 30;
    stmt1.Parameters.Add(p_data);

    stmt1.Prepare();

    while (AdminIns.Read()) {
        p_id.Value = AdminIns.GetInt64(0);
        p_data.Value = AdminIns.GetString(1);
        stmt1.ExecuteNonQuery();
    }
    stmt1.Close();
}

DbType property
Direction property
IsNullable property
ParameterName property
Precision property
Scale property
Size property
Value property