|
Database Connection How To |
|
|
|
Friday, 18 August 2006 |
|
How to configure a database connection (using SQL Server in this example): //The connection string to be used in web.config file. //It is configured to use SQL server express 2005 version. <connectionStrings> <add name="myConnectionString" connectionString="Data Source=LOCALHOST\SQLEXPRESS;Initial Catalog=databaseName;Persist Security Info=True;User ID=sa;Password=123" providerName="System.Data.SqlClient" /> </connectionStrings> ...
How to use: SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString);
conn.Open(); ....//any code... conn.Close(); |
|
Last Updated ( Tuesday, 31 October 2006 )
|