Forum Home › Forums › Development and Integration › How to modify many database fields content easily?
- This topic has 9 replies, 3 voices, and was last updated 4 years, 6 months ago by Mikhail.
-
AuthorPosts
-
June 27, 2016 at 1:46 pm #1347inpelsaParticipant
Hi,
Some channels got wrong data on a device for up to one hour.
I wonder if there is any way to update all that data easily instead of going minute row by row and channel to update it.
“All my data are belong to you!” :_(
June 27, 2016 at 2:08 pm #1348inpelsaParticipantwell… I just saw it was for 4 hours…
June 27, 2016 at 3:10 pm #1349MikhailModeratorHi,
A simple application is needed to update data because the archive is not SQL database.June 29, 2016 at 8:36 am #1368inpelsaParticipantI already fixed data but I’m curious…
On http://rapidscada.org/integration-with-rapid-scada/ section “First Way. Direct File Access” you talk about loading data:
using Scada.Data; ... SrezTableLight snapshotTable = new SrezTableLight(); SrezAdapter adapter = new SrezAdapter(); adapter.FileName = @"C:\SCADA\ArchiveDAT\Cur\current.dat"; adapter.Fill(snapshotTable); foreach (SrezTableLight.Srez snapshot in snapshotTable.SrezList.Values) { int cnlCnt = snapshot.CnlNums.Length; Console.WriteLine("Snapshot {0}, number of channels is {1}:", snapshot.DateTime, cnlCnt); for (int i = 0; i < cnlCnt; i++) { Console.WriteLine(" Channel[{0}] = {1}, {2}", snapshot.CnlNums[i], snapshot.CnlData[i].Val, snapshot.CnlData[i].Stat); } }
As I see a .Fill() that would not keep linked adapter and table data objects…
How can data be modified ?
I cannot see any update/save method. Is SaveToFile the only way?Thanks!
June 29, 2016 at 10:17 am #1370MikhailModeratorYou should use srezAdapter.Update(srezTable) method after modify data in srezTable.
Changing data:
https://github.com/RapidScada/scada/blob/master/ScadaServer/ScadaServerCtrl/FrmSrezTableEdit.cs#L331Saving: https://github.com/RapidScada/scada/blob/master/ScadaServer/ScadaServerCtrl/FrmSrezTableEdit.cs#L103
“Srez” means a snapshot ))
July 1, 2016 at 5:01 pm #1382inpelsaParticipantTo anyone interested…
Taking the source code of Scada server (building /solving references) and doing following modifications you got it!:
In FrmSrezTableEdit.cs set:
– datagridview1.multiselect = true
– Add a label, textbox and command button near the SQL filter
– Add this code on Update command button:private void btnUpdate_Click(object sender, EventArgs e) { Int32 numloops = 0; foreach (DataGridViewRow row1 in dataGridView1.SelectedRows) { dataGridView1.CurrentCell = dataGridView1.Rows[row1.Index].Cells[0]; foreach (DataGridViewRow row2 in dataGridView2.Rows) { row2.Cells[1].Value = txtNewValue.Text; dataTable2.AcceptChanges(); } if (numloops % 10 == 0) { Application.DoEvents(); } numloops++; } }
It will allow you to select a datetime range, a channel/value filter and update all data valuees at a time.
Not nice (even more if I’m not an expert on C#), but will reduce any update task from hours to minutes…
- This reply was modified 7 years, 10 months ago by inpelsa.
July 1, 2016 at 6:54 pm #1385MikhailModeratorThe great approach! I think it should be included in the SCADA-Server shell.
July 4, 2016 at 9:14 am #1391inpelsaParticipantPlease, feel free to add it yourself with nice code 😉
Even more, if you add a 2nd textbox for the status value (plus some program logic to modify data only in case a value is written) and a way to select a range of days to modify… it should be more than enough!!!
October 2, 2019 at 1:48 am #5986kejtanParticipantHi Mikhail,
I am experiencing a similar problem and need to modify the existing data. I am currently using v5.7.1. Is there any tools available for such manipulation or do I need to do it via the source code method? Thanks!
October 2, 2019 at 10:26 am #5987MikhailModeratorHi,
To find the best method, please provide an example what do you need to update. -
AuthorPosts
- You must be logged in to reply to this topic.