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 you mean by filtering of data?
Explain how can we load multiple tables in to dataset?
Which object needs to be closed?
Describe connection object in ado.net
What are datareaders?
What are the major challenges in accessing data from a database?
What do you mean by ‘batch updates’?
How can you identify whether or not any changes are made to the DataSet object since it was last loaded?
Which database is the ado.net sql connection object designed for?
Do we use stored procedure in ADO.Net?
What is dataset object? Explain the various objects in dataset.
What are the steps you will take to improve performance? Will you use dataset or datareader?
What is a datareader object?
Explain the basic use of "dataview" and explain its methods.
What is sqldatareader in ado.net?