How to you declare connection strings and how to you make
use of web.config ?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
What is the role of clr?
What is the difference between connected environment and a disconnected environment?
What is difference between executenonquery and executequery?
ADO.NET is Disconnected Architecture. DataReader is connected Architecture, but DataReader is a part of ADO.NET. How is it possible?
What is connection string?
What are the essential features of ado.net?
What is a dataset?
What provider ado.net use by default? Explain the role of data provider in ado.net? What is the role of data provider in ado.net?
Differences between dataset.clone and dataset.copy?
What are the namespaces used in ado.net for data access?
What is dataset and tell about its features. What are equivalent methods of previous, next etc. Of ADO in ADO.NET ?
What is bubbled event can you please explain?