Return data from a table in Web.config

Asked

Viewed 153 times

2

I develop an application, which will be implemented in several companies, and we will need to make changes to the connectionString in each of them( because they already have servers installed, with the database).

However, the technicians who will carry out the implementation, need a way to make the connection with the database, without having to change the connectionString manually.

To remedy this problem, I inserted a table containing the company data( name, address, etc.) and would like to know, if it is possible to put the data of connectionString in some table, and return the value in Web.config( so technicians will only have to fill in the form with the instance, the database, user, etc) thus configuring the connectionString.

  • Hello, what database connection technology are you using? Let me see if I understand. You will create a table in the BANK to tell the BANK connection string to connect to the BANK and return the string that will be used to connect to the BANK?

  • I expressed myself badly. Not create a table, but some way to save this data and send it to my connection string. I am using Asp.NET MVC with Sqlserver 2008.

  • You want the connection string to change per user without anyone changing?

  • No, just offer a form, where the technician informs the "Server Instance" "User, Password", and the "Bank" used. And this information is stored in my connectionString on Web.config

1 answer

2


Hello,

Just put 4 text fields for the technician to inform SERVER + BANK + USER + PASSWORD

And with the contents of the text fill

var section = (ConnectionStringsSection)configuration.GetSection("connectionStrings");
section.ConnectionStrings["MyConnectionString"].ConnectionString = "data source="+SERVIDOR+";initial catalog="+BANCO"+;multipleactiveresultsets=True;User ID="+USUARIO"+;Password="+SENHA+";";

And for him not to have to keep typing this data every login, just save in the app.config.

http://www.codeproject.com/Articles/14744/Read-Write-App-Config-File-with-NET http://geekswithblogs.net/akraus1/archive/2006/01/04/64871.aspx

A problem similar to yours here:

https://stackoverflow.com/questions/719928/how-do-you-modify-the-web-config-appsettings-at-runtime

Browser other questions tagged

You are not signed in. Login or sign up in order to post.