I am writing a program to manage a office. (Getting rid of Excels XD).
I have a DAL class with the following variables:
private MySqlConnection connection;
private DataSet ds;
private Hashtable adapters;
There is this method:
public bool AddTable(string tableName, string sqlStat)
{
if (!ds.Tables.Contains(tableName))
{
MySqlDataAdapter adapter = new MySqlDataAdapter(sqlStat, connection);
MySqlCommandBuilder builder = new MySqlCommandBuilder(adapter);
adapter.InsertCommand = builder.GetInsertCommand();
adapter.UpdateCommand = builder.GetUpdateCommand();
adapter.DeleteCommand = builder.GetDeleteCommand();
adapter.Fill(ds, tableName);
adapters.Add(tableName, adapter);
return true;
}
return false;
}
The program will be connected to a server with MySQL database. I need to make sure that when one client changes something in the database another client will see the new data, but this is not happening.
You need to read up on optimistic concurrency, which helps solve the problem of multiple users reading and updating the same data at the same time.
I suggest you start here: