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

Explain how to copy the contents from one table to another table and how to delete the source table in ado.net?

868


How to pass multiple tables in datasets simultaneously?

1058


What are the types of databinding?

993


Why is ADO.NET serialization slower than ADO ?

1054


How does entity framework work?

922


What does adodb stand for?

1054


What is the namespaces being used to access oracle database?

1081


What is dataset and datatable in ado.net?

999


What are the benefits of ADO.NET?

1121


What is difference between ado.net and asp net?

1041


Explain the difference between data reader and data set?

927


Can we load multiple tables in a dataset?

1134


What is the difference between linq and ado.net?

999


Why do we serialize data?

945


Why is it important to close an ado.net application?

1022