G
Guest
Hello
I have a Access Database that is connected by an OledbConnection. At this point the Access database is located on the same PC as the application that connects with the database, but it's going to be on a different PC. Regarding database connections I've found that there are a lot of different solutions. In a lot of cases it's said that connections should be opened "as late as possible" and closed immediately after the database operation is finished. Other solutions say that if you're using a remote database you should open one connection and open it and only close it if you close the application, because of overhead issues
Well, I did the last thing, but now I don't know if that was an intelligent action ;-). At this point I have three applications with each their own OledbConnection. So there are three connections with the Access Database. This connection is shared and within the application I assign this connection to the OledbCommands. This worked fine, but I recently discovered that sometimes commands aren't executed beacause the connection is "Open, Executing". This is very frustrating, because I cannot rely on database actions to be executed
Another thing that bugs me is the fact that in the Sub New I have to manually asign the connection to the commands (either "stand-alone" or from within a dataadapter). I think this is an ugly solution, as well as the fact that in a lot of Design-views I use a connection only for designing (because the re-assignment of the shared connection in New); the "Design-connection" is automatically added when a new dataadapter is added
That last point got me thinking that I'm doing something wrong or at least not in the way Microsoft thinks it should be done. On the other hand this mechanism works much faster then opening and closing seperate connections all the time. The last solution creates a lot of connections, that is, in every object that has a dataadapter/command it has a connection as well. And I had the idea that that solution used a lot of resources
So, in short: I have multiple PC's with applications that all want to connect to an Access database on a server. What kind of connection is the best to use and where I know that commands are actually executed
Thanks for your time
Best regards
Michiel Doeven
I have a Access Database that is connected by an OledbConnection. At this point the Access database is located on the same PC as the application that connects with the database, but it's going to be on a different PC. Regarding database connections I've found that there are a lot of different solutions. In a lot of cases it's said that connections should be opened "as late as possible" and closed immediately after the database operation is finished. Other solutions say that if you're using a remote database you should open one connection and open it and only close it if you close the application, because of overhead issues
Well, I did the last thing, but now I don't know if that was an intelligent action ;-). At this point I have three applications with each their own OledbConnection. So there are three connections with the Access Database. This connection is shared and within the application I assign this connection to the OledbCommands. This worked fine, but I recently discovered that sometimes commands aren't executed beacause the connection is "Open, Executing". This is very frustrating, because I cannot rely on database actions to be executed
Another thing that bugs me is the fact that in the Sub New I have to manually asign the connection to the commands (either "stand-alone" or from within a dataadapter). I think this is an ugly solution, as well as the fact that in a lot of Design-views I use a connection only for designing (because the re-assignment of the shared connection in New); the "Design-connection" is automatically added when a new dataadapter is added
That last point got me thinking that I'm doing something wrong or at least not in the way Microsoft thinks it should be done. On the other hand this mechanism works much faster then opening and closing seperate connections all the time. The last solution creates a lot of connections, that is, in every object that has a dataadapter/command it has a connection as well. And I had the idea that that solution used a lot of resources
So, in short: I have multiple PC's with applications that all want to connect to an Access database on a server. What kind of connection is the best to use and where I know that commands are actually executed
Thanks for your time
Best regards
Michiel Doeven