258
13 DATABASE FUNCTION
13.3 CPU Module Database Access (from External Device) Function
// Processing the search results one record at a time
for (int recordnum = 0; reader.Read(); re+)
{
// Adding a blank row to the list
dtRecord.Rows.Add();
Setting the number of rows to be inserted into the list
recordnum = dtRecord.Rows.Count-2;
Storing acquired records into the list one field at a time
for (int i = 0; i < len; i++)
{
// Adding search results into the list
dtRecord.Rows[recordnum].Cells[i].Value = reader.GetValue(i);
}
// Plotting values of X and Y fields on the graph
chart1.Series[0].Points.AddXY(Convert.ToInt32(dtRecord.Rows[recordnum].Cells[2].Value),
Convert.ToInt32(dtRecord.Rows[recordnum].Cells[3].Value));
}
}
catch (OdbcException ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
// Disconnecting from DB
cn.Close();
}
}
/// <summary>
/// Generating the SQL statement from the value in the combo box
/// </summary>
public string GetSQL()
{
string strSQL = "";
switch (cmbJudge.SelectedIndex)
{
case 0:
// The search target is records of Judge = 0.
strSQL = "SELECT SerialNo, Enduser, X, Y, Z, Judge FROM CheckData WHERE Judge=0";
break;
case 1:
// The search target is records of Judge = 1.
strSQL = "SELECT SerialNo, Enduser, X, Y, Z, Judge FROM CheckData WHERE Judge=1";
break;
case 2:
// Acquiring all the records
strSQL = "SELECT SerialNo, Enduser, X, Y, Z, Judge FROM CheckData";
break;
default:
strSQL = "SELECT * FROM CheckData";
break;
}
return strSQL;
}
}
}
Summary of Contents for MELSEC iQ-R-R00CPU
Page 2: ......
Page 151: ...9 MONITOR FUNCTION 9 1 Real Time Monitor Function 149 9 MEMO ...
Page 323: ...18 SEQUENCE SCAN SYNCHRONIZATION SAMPLING FUNCTION 321 18 MEMO ...
Page 330: ...328 20 ROUTING SETTING 20 3 Precautions MEMO ...
Page 423: ...26 BASIC CONCEPT 26 8 State Transition of the Redundant System 421 26 MEMO ...
Page 1014: ...1012 APPX Appendix 15 Added and Enhanced Functions MEMO ...
Page 1027: ......