Saturday, December 6, 2008

Writing Connection string in web.config file

0 comments 12/06/2008
Sign up to receive our site updates!
In Web.config file













<appsettings><add key="sqlconstrusingappset" value="server=FOCALPOI-392A7D\SQLEXPRESS;user id=raji;password=chekuri;database=raji"> </add></appsettings> <connectionstrings> <add connectionstring="server=FOCALPOI-392A7D\SQLEXPRESS;user id=raji;password=chekuri;database=raji" name="sqlconstr"> </add></connectionstrings>




In .CS file


string str = ConfigurationManager.ConnectionStrings["sqlconstr"].ToString();

string str1 = ConfigurationManager.AppSettings[0].ToString();
or
string str1 = ConfigurationManager.AppSettings["sqlconstrusingappset"].ToString();
//connection string using ConnectionString
con = new SqlConnection(str);
or
//connection string using AppSettings
con = new SqlConnection(str1);
con.Open();
Your Ad Here

0 comments:

Respects for your's Questions & Opinions

  • Friends
  •  

    Recent Posts

    New Comments

    Copyright 2008 All Rights Reserved Tech Tasks Template by Rajesh Kumar Chekuri