Rank: Newbie Groups: Member
Joined: 10/27/2009 Posts: 2 Location: Buenos Aires, Argentina
|
Hello, I've trying to insert data through PI OLEDB with the following code: Code: using (OleDbConnection conn = new OleDbConnection(connstr)) { try { conn.Open();
string tag = 'TI_AW1'; DateTime timestamp = new DateTime(2009, 08, 31, 08, 10, 54); decimal value = 22.45;
OleDbCommand cmd = new OleDbCommand(conn); string sql_insert = "INSERT INTO piarchive..picomp2 (tag, time, value, annotations) VALUES ('{0}', '{1}', {2}, 'Manually created')"; cmd.CommandText = string.Format(sql_insert, tag, timestamp.ToString("dd-MMM-yy hh:mm:ss"), value); cmd.CommandType = System.Data.CommandType.Text; cmd.ExecuteNonQuery(); } catch (Exception e) { Console.Error.WriteLine(e.Message); } finally { conn.Close(); } }
but when I go to ProcessBook I can saw the data for a few minutes and after that the data disapear. What is wrong with this code or what I forget to do? Thanks in advance.
|
Rank: Member Groups: Member
Joined: 9/23/2008 Posts: 15 Location: Pennsylvania, USA
|
Was the tag created before or in the archive that you are writing to? If the tag was created after the archive it will not be able to save the value unless you reprocess the archive.
|
Rank: Newbie Groups: Member
Joined: 10/27/2009 Posts: 2 Location: Buenos Aires, Argentina
|
Thanks, you are right. I'll go to reprocess the archive. At the moment, I did a test with an old tag into disuse and is working.
|