Tjazz Tjazz - 1 month ago 5x
SQL Question

Search database for value and get info c# Forms

I have a database called "users" where user information is saved. When you login with your name and pass, your name is send to the homeform, where i want to get the "to-do list" that's saved in the database with your info. Here's my code so far:

MySqlCommand cmd = new MySqlCommand();
cmd.CommandText = "SELECT * FROM `user` WHERE `username`=@username AND `todo`=@todo";

So basically i need to get the todo of the user (which is sent to this form as _name) lets say admin, and display it in tbTodo.


if it is in the same form you can try using

select `user`.todo from `user` where `username` = @username 

considering username is unique