ASP.NET using C# InitConnection() Issue
-
I am using the visual studio designer and creating table adapters and strongly typed datasets. The question I have is how to override the InitConnection() method the designer creates for you. I have two connection strings I would want to use (say local and remote). So I want to extend/enhance this method to determine which one it should be using. Any thoughts?
-
I am using the visual studio designer and creating table adapters and strongly typed datasets. The question I have is how to override the InitConnection() method the designer creates for you. I have two connection strings I would want to use (say local and remote). So I want to extend/enhance this method to determine which one it should be using. Any thoughts?
No need to override it if you use ASP.NET 2.0, there should be a ConnectionString setting in web.config. Change that and you can either use your local or remote database. In ASP.NET 1.1 you will need to set the ConnectionString property of the connection that is used by the commands of the DataAdapter.
WM. What about weapons of mass-construction? "What? Its an Apple MacBook Pro. They are sexy!" - Paul Watson My blog
-
No need to override it if you use ASP.NET 2.0, there should be a ConnectionString setting in web.config. Change that and you can either use your local or remote database. In ASP.NET 1.1 you will need to set the ConnectionString property of the connection that is used by the commands of the DataAdapter.
WM. What about weapons of mass-construction? "What? Its an Apple MacBook Pro. They are sexy!" - Paul Watson My blog
I was going to do that, but I was also looking for a programmatic way to do it. Previously, I had made my own custom data layer and included logic for it to determine which environment it was in, local or remote. This way I wouldn't have to update the web.config when I published. I tried to use a partial class, either I didn't do it correctly, or it just didnt work.