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
How to copy the contents from one table to another table and how to delete the source table in ado.net?
What is ole access?
How does entity framework work?
Does dapper use ado.net?
What is command class in ado.net?
What is sqldatareader in ado.net?
Name which operations can you not perform on an ado.net dataset?
Explain what are the steps to connect to a database?
What are two important objects of ADO.Net?
What does executequery return?
What is connection pooling and what is the maximum pool size in ado.net connection string?
What are the advantage of ado.net?
Explain executenonquery?
How does ado.net work?
What is the difference between an ADO.NET Dataset and an ADO Recordset?