I'll be around :)
I was reading through our conversation and started thinking about concepts. Just to make sure we are discussing this from the same point of view, here is an intro to db user concepts and application users.
If you create a User in C# as a class, this has nothing to do with the user accessing the mysql database
A good practise is to have two kinds of users for the database. one with read rights and one with read/write rights. This way you can use the read user when doing searches in the system and that way protecting the system from malicious code in form inputs. And in the same way, only use the write user when you want to add, update or remove data in the database.
To clarify: In your database you only need two separate users no matter how many users you have in your c# application.
To limit users of your C# application to see only data in the database that is meant for them you need to have some way to identify each user. Very common is a user ID which is basically a field in your class with type int... something like this:
-
// a class in some namespace
-
public class User {
-
-
int id;
-
string username;
-
string password;
-
-
//additional info
-
-
public User(int id) {
-
-
// fetch data from the database about this user here
-
}
-
For the database to know which data belongs to which user you need to add a field in each table that says "This info is about this user".
You do that by adding a column in your table. Name it something appropriate like user_id and just like the field id in your c# class, it should be an int.
Say you have a table about dogs:,
-
------------------------------
-
| Table : dogs
-
------------------------------
-
| name
-
| breed
-
| height
-
| weight
-
| owner // this column is your user_id from the c# app
-
-------------------------------
-
So, now each dog has an owner which you can identify through the user id which in this table is known as owner
You should also store your application users in your database. for instance like this.
-
------------------------------
-
| Table : users
-
------------------------------
-
| user_id
-
| username
-
| password
-
-------------------------------
-
Now you can see which user owns which dog and do combined searches on them through SQL.