How to you declare connection strings and how to you make
use of web.config ?
Answer Posted / 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 |
Post New Answer View All Answers
What Is Difference Between Ado And Ado.net?
What is sql command in ado net?
How to load multiple tables into a dataset?
What is the return type of executescalar?
What is the use of connection object in ado.net?
Describe ado.net object model in detail.
What is command class in ado.net?
What are the Features of a dataset
What is ado net stands for?
What does sqldatareader return?
What are the core objects of ADO.NET?
What is the hierarchy of data in databases?
Is entity framework better than ado.net?
Name which operations can you not perform on an ado.net dataset?
Explain the difference between data reader and data set?