Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How to you declare connection strings and how to you make
use of web.config ?

Answers were Sorted based on User's Feedback



How to you declare connection strings and how to you make use of web.config ?..

Answer / prasad

In web.config file just plase

<appSettings>
<add key="ConStr" value="Provider=SQLOLEDB.1;User
ID=sa;Initial Catalog=Sample;Data Source=ABC"></add>
</appsettings>

and in CS file

sqlconnection con = new sqlconnection
(ConfigurationSettings.AppSettings["ConStr"]);

and u can u this connection any where in ur App.

Is This Answer Correct ?    4 Yes 0 No

How to you declare connection strings and how to you make use of web.config ?..

Answer / d0tnetf0x

In web.config,we have to give connection to database by add
key which is given in application setting tags.as

<appsettings>
<add key="constr" value="Data Source=SQL-PC;Initial
Catalog=sampledb;User ID=sa;password=password "/>

</appsettings>

//under value we have given the database which is connected.
here under ----data source=servername
intial catalog=database name
user id=username of the database(if give)
password= password(optional)

to use this connection we use configsetting or we caneven
directly give it in sqlconnection

sqlconnection conn=new sqlconnection
(configurationsetting.appsettings("constr"))
here constr is the key we added in application settings to
identify it in web.config
[this connection we used by declearing in web.config]

with out declearation:-
sqlconnection conn=new sqlconnection("Data Source=SQL-
PC;Initial Catalog=sampledb;User ID=sa;password=password ")

better process is useing connection by declearing in
web.config

Is This Answer Correct ?    1 Yes 0 No

How to you declare connection strings and how to you make use of web.config ?..

Answer / ansu kumar

in
web.config file
<appsetting>
<add key="constr" value="data source=database name;
database=database name"/>
</appsetting>

and
in .aspx file
string str=configurationsetting.appsetting.constr;

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More ADO.NET Interview Questions

What is different between sqlcommand object and command behavior object?

0 Answers  


What are all the different authentication techniques used to connect to MS SQL Server?

0 Answers  


Call a stored procedure from ado.net and pass parameter to it ?

7 Answers   Keane India Ltd, TCS,


What is full form of ado?

0 Answers  


What is the difference between data reader and data adapter?

0 Answers  


What are dataproviders?

0 Answers  


What are the steps in connecting to database?

3 Answers   IBM, Microsoft,


What is Data Provider?

0 Answers  


How to find the count of records in a dataset?

6 Answers  


What is reference by value how does it works in .net?

2 Answers   SQL Star,


How to generate XML from a dataset and vice versa?

2 Answers  


What are the steps you will take to improve performance?

0 Answers  


Categories