admin管理员组文章数量:1297064
I am trying query few Historian tags data from Proficy Historian using OleDbDataAdapter. The code pulls the data right from the historian but when I am trying to merge the data in a common Data table, it doesn't merge it with common timestamp row. Current result from the code is like:
Current result
Expected result
Here is my existing code:
public DataTable GetHistorianDataTable() {
string[] mytags = { "USAATL1.PRPAST_CIP_RECIPE_STEP_NUM.F_CV",
"USAATL1.PRPAST_CIP_CONTROL_STEP_NUM.F_CV",
"USAATL1.FIT_D31_0170_TARGET.F_CV",
"USAATL1.FIT_D31_0170_VALUE.F_CV",
"USAATL1.AIT_D30_1090_TARGET.F_CV" ,
"USAATL1.AIT_D30_1090_VALUE.F_CV" ,
"USAATL1.TIT_D31_0060_TARGET.F_CV" ,
"USAATL1.TIT_D31_0060_VALUE.F_CV",
"USAATL1.TIT_D31_0060_TARGET.F_CV",
"USAATL1.TIT_D31_0060_VALUE.F_CV"
};
string[] columns = { "Recipe_Step",
"Control_Step",
"FIT_D39_0220_TARGET",
"FIT_D39_0220",
"AIT_D39_0040_TARGET" ,
"AIT_D39_0040" ,
"TIT_D39_0045_TARGET" ,
"TIT_D39_0045",
"FIT_D39_0055_TARGET",
"FIT_D39_0055"
};
int n = 11; // the number of datatables
DataTable[] dtArray = new DataTable[n];
for (int i = 0; i < n; i++)
dtArray[i] = new DataTable("DtTbl " + i);
DataTable table = new DataTable();
table.Columns.Add("timestamp", typeof(DateTime));
for (int i = 0; i < mytags.Length; i++)
{
DataTable temptable = new DataTable();
string query = "SELECT timestamp, value, FROM ihRawData " +
"WHERE tagname = '" + mytags[i] + "' " +
"AND samplingmode=Calculated " +
"AND intervalmilliseconds=30s " +
"AND timestamp>='03/29/2024 13:58:59' " +
"AND timestamp<='03/29/2024 14:22:59' ";
}
for (int i = 0; i < n; i++)
{
table.Merge(dtArray[i], false, MissingSchemaAction.Add);
}
return table;
}
public DataTable GetDataTbl(DataTable tbl, string cmdtext)
{
OleDbConnection Connection;
string provider = ConfigurationManager.ConnectionStrings["HistorianDb"].ConnectionString;
Connection = new OleDbConnection(provider);
OleDbDataAdapter adapter = new OleDbDataAdapter(cmdtext, Connection);
adapter.Fill(tbl);
return tbl;
}
本文标签: C OleDbDataAdapter Fill and merge table function not working as expectedStack Overflow
版权声明:本文标题:C# OleDbDataAdapter Fill and merge table function not working as expected - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741647427a2390267.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论