Mitsubishi Electric MELSEC iQ-R-R00CPU User Manual page 260

Melsec iq-r series cpu module application user's manual
Table of Contents

Advertisement

// Processing the search results one record at a time
for (int recordnum = 0; reader.Read(); recordnum++)
{
// 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),
}
}
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;
}
}
}
13 DATABASE FUNCTION
258
13.3 CPU Module Database Access (from External Device) Function
Convert.ToInt32(dtRecord.Rows[recordnum].Cells[3].Value));

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents