SQL connection in the app.config file?

SQL connection in the app.config file?

Old forum URL: forums.lhotka.net/forums/t/12787.aspx

dong posted on Tuesday, October 28, 2014

After the load is connected to the variable string "connectionString", Question of the standard functions of C # can be taken out each piece as: [Server = localhost] and [Port = 5432] and ... [CommandTimeout = 10], to give them form into log form as SQL Server Management Studio 2005 from here Modifying, update, add delete, ... and after the break will be saved to the app.config file

JonnyBee replied on Sunday, November 02, 2014

Not quite sure what your question is here. 

Most database drivers provide a ConnectionStringBuilder that will help you to set the necessary properties ang get the result connectionstring.


var csb = new System.Data.SqlClient.SqlConnectionStringBuilder();
csb.DataSource = "myserver";
csb.InitialCatalog = "mydatabase";
csb.IntegratedSecurity = true;

Will give this output (connection string):
Data Source=myserver;Initial Catalog=mydatabase;Integrated Security=True

You will have to update app/web config manually tho'.


dong replied on Tuesday, November 04, 2014

ok, thanks

Copyright (c) Marimer LLC