Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

If we want to connect to many databases in dataaccess layer
such as MSAccess,Sql server,oracle means not to a particular
database depends on condition we have to connect to
appropriate database in this scenario if we without changing
code Ho wdo you handle this situation?

Answer Posted / suresh jayaraman

<configuration>
<appSettings>
<add key="AccessDatabase" value="Data
Source=servername;Initial
Catalog=databasename;uid=userid;pwd=password"/>
<add key="SqlServerDatabase" value="Data
Source=servername;Initial
Catalog=databasename;uid=userid;pwd=password"/>
</appSettings>
</configuration>

and use this Key name where it is needed

If you need SqlServer DataBase

using System.Data.SqlClient;

in DataAcess Layer


public SqlConnection Connection()
{
try
{
con = new SqlConnection
(ConfigurationManager.AppSettings
["SqlServerDatabase"].ToString().Trim());

return con;

}
catch (Exception exp)
{
throw exp;
}
}

Is This Answer Correct ?    2 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the steps you will take to improve performance?

935


What is ado asp?

1035


Which object holds only data and does not interact with data source?

1029


What are the namespaces used in ado.net for data access?

1024


How can we load multiple tables in a dataset?

1232


What is the difference between connected and disconnected environment?

1163


How do you find the count of records in a dataset?

1019


Which is faster sqldataadapter and sqldatareader?

972


What is the difference between ado.net and entity framework?

1088


What is meant by ‘transaction’ in a database and what are the ‘properties of transaction’?

1038


What are disadvantages of microsoft-provided data provider classes in ado.net?

1084


What is the difference between Optimistic and Pessimistic locking?

1032


How do you update a dataset in ado.net?

1053


What is difference between executenonquery and executequery?

1019


Is datareader faster than datatable?

1014