I’m trying to implement a function to view the most recently added item to a SQL Server CE database:
private void BackButt_Click(object sender, EventArgs e)
{
try
{
SqlCeDataReader myReader = null;
SqlCwCommand cm = new SqlCeCommand("SELECT MAX(TS_Process) AS Expr1, MAX(TS_Verify) AS Expr2 FROM TestStep", cn)
myReader = cm.ExecuteReader();
while (myReader.Read())
{
stepTB.Text = myReader.GetString(0);
ExpectedTB.Text = myReader.GetString(1);
}
}
catch (SqlCeException ex)
{
MessageBox.Show(ex.Message);
}
Connection is opened at form load.
This only displays the last entry and does not display all previous entries.
Any help would be greatly appreciated.
Thanks
quick and easy fix, below code will do what you asked, altho this is not the way you’re gonna want to use it.
if you want an actual overview, look up datacontrols such as repeaters and gridviews.