Using Dynamic Connection String in Asp.Net Webforms and Windows Forms

1

I'm working on a project with 4 layers ( Banco , RegraNegocio , Webforms and Windows Forms ).

I made the following references:

  

Webforms > Business Rule > Bank
winforms > Business Rule > Bank

In my Class Library ( bank ) I have a file called: config.settings

In this file I have only two properties of type string .

  

strconnection - where the connection is stored.

     

infobank - where is stored which database is, eg: (access, sqlserver, postgre)

I assign values to these properties when the login is done (winforms). They work fine, but when I was using asp.net it gives an error, saying that I can not use arquivo.settings .

I changed the scope of the User variables to application , but execution does not allow me to assign values to them at run time. The properties have only {get;} when the scope is the application scope.

Does anyone know what I can do to store the connection string? Because I access a database where customer records are stored, I get the connection string inside the table, then access the database of the respective client.

On desktop it was simple: it was stored in config.settings and it already exits using methods and class because every time I send a command it opens the new connection using the strConnection property > that I initialized when the user logged in.

    
asked by anonymous 19.02.2016 / 18:18

1 answer

1

If you access the folder of your web application you will see that the config.settings file is not found in the application directory. This happens because references to other projects are copied to the bin folder as assemblies , but the physical dependency files do not.

Files must be replicated in the web environment manually (yes, you will have to create a copy) or you can put the information from this file in a

19.02.2016 / 20:54