WE can't see the definitions of
loginUser
and
user
which are the only explicit casts in that code; we also can't see what type
SQLuserAccess.UserLogin
returns, or what is in
user
before you cast that.
So run your code in the debugger, and look at exactly what the variables contain.
At a guess, you say that Customer is derived from User but I'd suspect that UserLogin returns a member of the base User class, not a Customer - and you can't "up-cast" anything.
public class User {}
public class Customer : User {}
...
Customer c;
User u = new Customer ();
c = (Customer) u;
u = new User();
c = (Customer) u;