I have a table in mysql called Users that has 4 rows. ID, Name, pass, company.
I try to make an application in c# WPF that does this : You add the user and give the values that you have to give, and you must also give the company that he belongs too.
Now, what i need to do is find a way to give the company's name and say : Where company's name is Google, place in the user in the field company the id 1
ID Name
1 Google
2 Facebook
3 Instagram
4 etc_etc
And the code is :
public bool AddUser(string userid, string username, string password, int companyId)
{
return ExecQuery("insert into users (id, name, pass, companyid) values(@id, @name, @pass, @cid)",
cmd =>
{
cmd.Parameters.AddWithValue("@id", userid);
cmd.Parameters.AddWithValue("@name", username);
cmd.Parameters.AddWithValue("@pass", password);
cmd.Parameters.AddWithValue("@cid", companyId);
return cmd;
});
}
public bool AddCompany(string name)
{
return ExecQuery("insert into companies (name) values(@name)",
cmd =>
{
cmd.Parameters.AddWithValue("@name", name);
return cmd;
});
}