I'm working on a software using VB.Net which retrieves string packets through a TCP socket. The problem is it receives hundreds of packets per second. For each incoming packet the software should connect to the database (right now it's Access DB) and do one of the following:
- Query one row of the database and use some item's of it (no problem with this).
- Query one row, read some items, and then modify items in the same row.
- Query one row, read some items, and then modify items in another row.
Now obviously this need to be done as fast as possible, so I'm looking for a good way (using less resources as well) to handle this.
The only way I know to query & modify data in the same connection is to use disconnected mode (method #3) but I'm thinking that if I use disconnected mode to handle updating the data, that might cause some conflicts.
Here's what I thought of anyway:
Method #1 (Mix between connected & disconnected mode):
Create a function that uses DataAdapter and returns a variable of type DataRow contains the data of the found row. And then modify the row directly in the DB by using UPDATE.. SET statement and ExecuteNonQuery method.
Method #2 (All connected):
Create a function that uses DataReader and returns required items from the found row. And then modify the row directly in the DB by using UPDATE.. SET statement and ExecuteNonQuery method.
Method #3 (All disconnected):
Query and fill the found row into a DataTable using DataAdapter, and then update & save the row using CommandBuilder and DataAdapter.Update
So, I'm looking the best approach to handle this. Please offer other approaches if you think it's better than the 3 methods I mentioned.
Note: I'm using an Access database right now for comparability issues, and I'm planning to use MySQL in the future.