开发者

Enterprise Library Edit Connection And Check

开发者 https://www.devze.com 2023-01-28 12:23 出处:网络
I have created a connection and fetching data using the method given in the code section. Now I want a way where I take the database and server name as input from the user and save it to the same conn

I have created a connection and fetching data using the method given in the code section. Now I want a way where I take the database and server name as input from the user and save it to the same connection string i.e. "ConnString" in this case in the App.Config file. Also I need a way to check whether the new server name and database name are correctly provided by the user(I mean it makes a successfull connection). Please help.

private Database _db = EnterpriseLibraryContainer.Current.GetInstance<Database>("C开发者_如何学JAVAonnString");


Enterprise Library doesn't do anything along these lines. To change the connection string section in the config file, you'll need to go through the ConfigurationManager class to get the ConnectionStringsSection and modify that. Depending on your environment and security settings you may not have permissions to write to the config file, though, so be warned.

Validating the server name and database name will require writing some database specific code - I'm not sure exactly off the top of my head how / if it's done.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号