❔ login system saves data from user
Hi this is the code that i have and i dont know why but its showing me the username and not the realname on the label, why?
Button on Form1 to check if user credentials are correct and if user exists open MainMenu and display the realname of the user logged in.
11 Replies
This is what i have on MainMenu form
And this is my UserData class to save the information of the user
Use the debugger, see if the variables you get from the database are what you think they are
That's why I recommend using Dapper at least, instead of having to fuck around with loosely-typed readers
idk hwo to work with dapper mb
Easier than with ADO that's for sure
It's better to select the columns instead of relying on the order that * returns them in
This?
SELECT realname FROM Users WHERE username = @username AND password = @password
?Well you're reading 3 columns
So select 3 columns
id, realname, nivel
Something like this
But displaying this error:
System.InvalidCastException: 'The specific conversion isnt valid.'
on this line: int id = reader.GetInt32(0);
Thats because you didnt select id as the first column
Meanwhile, in Dapper land
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.