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
Which database is the ado.net?
Explain which name space is used to get assembly details?
What are the major challenges in accessing data from a database?
What are the data access namespaces in .NET?
I loaded the dataset with a table of 10 records. One of the records is deleted from the backend, how do you check whether all the 10 records were present while updating the data(which event and steps) and throw the exception 28 can datareader hold data from multiple tables?
How to pass values into a datatable?
What are the objects of ado.net?
What is difference between executequery and executeupdate?
Define the executescalar method?
What is ado.net explain with diagram?
What is an ado?
What is the maximum pool size in ado.net connection string?
How to check if the Dataset has records ?
What is sqldatareader in ado.net?
differance between ADO vs ADO.Net?