var oAdo, oMap, oRs, sSQL, bRes, aValues;
oAdo = pMe.Pm("../PmaAdo");
sSQL = "select * from table1";
// Opening the database, if not open:
if (!oAdo.DbIsOpen())
{
bRes = oAdo.DbOpen();
}
else
{
bRes = true;
}
// If the database is open, then continue
if (bRes)
{
// Opening the corresponding table
oMap = oAdo.RsOpen("", sSQL, "return:map;");
// Detects whether the opening operation was completed successfully
if (oMap.ErrorCode == 0)
{
oRs = oMap.Result;
// Detects whether the table is not empty
if (oRs.EOF && oRs.BOF)
{
// Pm.Debug("Table (recordset) contains no records");
return -3;
}
else
{
// If the table is not empty then it can be read as a 2-dimensional array
aValues = Pm.CreatePmArray();
aValues.LoadFromVbArray(oRs.GetRows());
return aValues;
}
}
else
{
// Pm.Debug("Table opening error");
return -2;
}
}
else
{
// Pm.Debug("Database opening error");
return -1;
}
"select * from table1 where ctime = (select max(ctime) from table1)"
var oAdo, oMap, sSQL, bRes, sTime;
oAdo = pMe.Pm("../PmaAdo");
// Time format for the MS SQL database
sTime = Pm.FormatDate(Pm.Time, 20);
// Time format for the Oracle database
sTime = Pm.FormatDate(Pm.Time, 21);
// Time format for the MySQL database
sTime = Pm.FormatDate(Pm.Time, 22);
sSQL = "insert into table1(ctime, ctemperature, cpress, cstatus, cnote) values (" + sTime + ", 12.5, 1.5, 5, 'New record - INSERT')";
// Opening the database, if not open:
if (!oAdo.DbIsOpen())
{
bRes = oAdo.DbOpen();
}
else
{
bRes = true;
}
// If the database is open, then continue
if (bRes)
{
// Execution of the SQL statement
oMap = oAdo.DbExecute("", sSQL, "return:map;");
// Checking whether adding operation was completed successfully
if (oMap.ErrorCode == 0)
{
// If the query result is a set of records, then it is possible to process it further
// Pm.Debug("New record was successfully written to the database");
return 1;
}
else
{
// Pm.Debug("Error of writing new record to the database");
return -2;
}
}
else
{
// Pm.Debug("Database opening error");
return -1;
}
var oAdo, oMap, sSQL, bRes, sTime;
oAdo = pMe.Pm("../PmaAdo");
// Time format for the MS SQL database
sTime = Pm.FormatDate(Pm.Time, 20);
// Time format for the Oracle database
sTime = Pm.FormatDate(Pm.Time, 21);
// Time format for the MySQL database
sTime = Pm.FormatDate(Pm.Time, 22);
sSQL = "update table1 set ctemperature = 26.5, cPress = 1.83, cstatus = 8, cnote = 'change record UPDATE' where ctime = " + sTime;
// Opening the database, if not open:
if (!oAdo.DbIsOpen())
{
bRes = oAdo.DbOpen();
}
else
{
bRes = true;
}
// If the database is open, then continue
if (bRes)
{
// Execution of the SQL statement
oMap = oAdo.DbExecute("", sSQL, "return:map;");
// Checking whether adding operation was completed successfully
if (oMap.ErrorCode == 0)
{
// If the query result is a set of records, then it is possible to process it further
// Pm.Debug("Current record was successfully modified in the database");
return 1;
}
else
{
// Pm.Debug("Error of record modification in the database");
return -2;
}
}
else
{
// Pm.Debug("Database opening error");
return -1;
}
var oAdo, oMap, oRs, sSQL, bRes;
oAdo = pMe.Pm("../PmaAdo");
sSQL = "select * from table1";
// Opening the database, if not open:
if (!oAdo.DbIsOpen())
{
bRes = oAdo.DbOpen();
}
else
{
bRes = true;
}
// If the database is open, then continue
if (bRes)
{
// Opening the corresponding table
oMap = oAdo.RsOpen("", sSQL, "lock:optimistic;return:map;");
// Detects whether the opening operation was completed successfully
if (oMap.ErrorCode == 0)
{
oRs = oMap.Result;
// If you want to add a new record, then it is not necessary to check whether the table is empty or not.
oRs.AddNew();
oRs.Fields.Item("ctime").Value = Pm.Time;
oRs.Fields.Item("ctemperature").Value = 12.5;
oRs.Fields.Item("cpress").Value = 1.5;
oRs.Fields.Item("cstatus").Value = 5;
oRs.Fields.Item("cnote").Value = "New record - AddNew";
oRs.Update();
if (oRs.Pm_LastErr == 0)
{
// If the query result is a set of records, then it is possible to process it further
// Pm.Debug("New record was successfully written to the database");
return 1;
}
else
{
// Pm.Debug("Error of writing new record to the database");
return -3;
}
}
else
{
// Pm.Debug("Table opening error");
return -2;
}
}
else
{
// Pm.Debug("Database opening error");
return -1;
}
var oAdo, oMap, oRs, sSQL, bRes, nTime;
oAdo = pMe.Pm("../PmaAdo");
nTime = Pm.Time;
sSQL = "select * from table1";
// Opening the database, if not open:
if (!oAdo.DbIsOpen())
{
bRes = oAdo.DbOpen();
}
else
{
bRes = true;
}
// If the database is open, then continue
if (bRes)
{
// Opening the corresponding table
oMap = oAdo.RsOpen("", sSQL, "lock:optimistic;return:map;");
// Detects whether the opening operation was completed successfully
if (oMap.ErrorCode == 0)
{
oRs = oMap.Result;
// Detects whether the table is not empty
if (oRs.EOF && oRs.BOF)
{
// Pm.Debug "Table (recordset) contains no records"
return -4;
}
else
{
oRs.MoveFirst();
do
{
if (oRs.Fields.Item("ctime").Value ==nTime)
{
oRs.Fields.Item("ctemperature").Value = 26.5;
oRs.Fields.Item("cpress").Value = 1.83;
oRs.Fields.Item("cstatus").Value = 8;
oRs.Fields.Item("cnote").Value = "Change record - PmaAdo/edit";
oRs.Update();
if (oRs.Pm_LastErr == 0)
{
// If the query result is a set of records, then it is possible to process it further
// Pm.Debug("Current record was successfully modified in the database");
return 1;
}
else
{
// Pm.Debug("Error of record modification in the database");
return -3;
}
}
oRs.MoveNext();
} while (!oRs.EOF);
}
}
else
{
// Pm.Debug("Table opening error");
return -2;
}
}
else
{
// Pm.Debug("Database opening error");
return -1;
}