Get the Counter of overall Run from Project and Script
Good morning guys,
i have a new problem.
I want to get the Counter how often a project or a script had been started.
The idea is when i start the project/script it writes, as soon as it finishes, everything into my database plus an integer for the Counter. Then when i start the same Project/script again the 'counter' is incremented (and so).
I tried it with ADODataset to retrieve the values in the database and tried to get the right counter with 'if-clauses', but it always counted everything wrong.
Besides when i start the project after each script the logs are being written into the database to get intermediate results while the whole project runs. So one problem is the increment is executed for the follow-up scripts although they run also for the first time. (But this problem is second-rated).
Does anybody have a sample code or an idea/a method for that?
For example i tried it with something like this (just for trial) -->
function Iterate() { var DSet; // Create the new IAQAADODataset object DSet = ADO.CreateADODataset(); // Specify the connection string DSet.ConnectionString = "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=test;Uid=uid;Pwd=pwd;"; // Specify the command type and text DSet.CommandType = cmdTable; DSet.CommandText = "testlogs1"; // Open the dataset DSet.Open(); // Process records of the testlogs1 table //var FName = DSet.FieldByName("Description").Value ; //var Count = DSet.FieldByName("Counter").Value; while (!DSet.EOF) { if (DSet.FieldByName("Description").Value == "Started the Script Select_BFR") { DSet.FieldByName("Counter").Value ++; Log.Message(DSet.FieldByName("Counter").Value); } else if (DSet.FieldByName("Description").Value == "Started the Script Enter_NPR") { DSet.FieldByName("Counter").Value ++; Log.Message(DSet.FieldByName("Counter").Value); } else { DSet.FieldByName("Counter").Value ++; } DSet.Next(); } return DSet.FieldByName("Counter").Value; DSet.Close(); }
...but it ended up with telling me 'dataset is not in insert or edit mode'. When i write
DSet.FieldByName("Counter").Value +1;
it doesn't increment anything and it is always '0'.