Hi.

lNr is an integer column in table Lestur.
Why is this OK:
SqlCeCommand cmd =
new SqlCeCommand("SELECT Count(*) FROM Lestur", Conn);
Int32 nCount = (Int32)cmd.ExecuteScalar();

but this:
SqlCeCommand cmd =
new SqlCeCommand("SELECT MAX(lNr) FROM Lestur", Conn);
Int32 nMax = (Int32)cmd.ExecuteScalar();

returns InvalidCastException?

Regards,
Gudni