I have 2 fields that will be inserted into my database ip address and datetime. Each time they are entered they are assigned a ScanID primary key so the value should increment with each entry. How do I select the last entry, the one with the highest ScanID or the one with the most current datetime?
I thought it would look like this:
but then when I try to call its fields like so:
it tells me that entry does not contain a value for ipaddress or for datetime.
Any help with this is appreciated.
I thought it would look like this:
Code:
var entry = (from s in context.tblIPAddresses
group s by s.ScanID into g
select g.OrderByDescending(t=>t.DateTime)).First();
Code:
lblCurrentIP.Text = entry.IPAddress;
lblNewDateTime.Text = entry.DateTime.ToString("f");
Any help with this is appreciated.
Comment