aFields | [optional] (Variant) A single name, or an array of column names or ordinal positions of the fields in the record. |
---|---|
aValues | [optional] (Variant) A single value, or an array of values for the fields in the new record.
If aFields is an array, then aValues must be also an array with the same number of members, otherwise an error occurs. The order of field names must match the order of field values in each array. |
var oDb = pMe.Pm("/TestAdoDb");
var oRs = oDb.RsOpen("table1", "SELECT * FROM table1", "cursor:static;lock:optimistic;");
var aColsName = Pm.Array1("name", "value");
var aValues = Pm.Array1("pi", 3.14);
if (oRs)
{
oRs.AddNew(aColsName, aValues);
oRs.Update();
if (oRs.Pm_LastErr != 0)
{
oRs.CancelUpdate();
}
}
var oDb = pMe.Pm("/TestAdoDb");
var oRs = oDb.RsOpen("table1", "SELECT * FROM table1", "cursor:static;lock:optimistic;");
if (oRs)
{
oRs.AddNew();
oRs.Fields.Item("name").Value = "pi";
oRs.Fields.Item("value").Value = 3.14;
oRs.Update();
if (oRs.Pm_LastErr != 0)
{
oRs.CancelUpdate();
}
}
var oDb = pMe.Pm("/TestAdoDb");
var oRs = oDb.RsOpen("table1", "SELECT * FROM table1", "cursor:static;lock:optimistic;");
var aColsName = Pm.Array1("name", "value");
var aValues = Pm.Array1("pi", 3.14);
if (oRs)
{
oRs.AddNew();
oRs.Update(aColsName, aValues);
if (oRs.Pm_LastErr != 0)
{
oRs.CancelUpdate();
}
}
var oDb = pMe.Pm("/TestAdoDb");
oDb.DbExecute("", "INSERT table1 (name, value) VALUES ('pi', 3.14)", "");
if (oDb.LastErr != 0)
{
// ...
}