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?
Answers were Sorted based on User's Feedback
Answer / alok saxena
Hey!
You are giving clue in your question.
First We have to use select case option, In each case we
have to use respective database connection,pwd,
Mind you must have to select approrpiate provider e.x. Sql
u must use System.Data.Sql
Wish u a good luck
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / ganesh
Create appropriate provider at run time(use factory
patterns) based on some configurations setting (probably a
XML file).This will allow user to decide providers
dynamicallly and enable connecting to whatever database he
wants
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / koteswara rao.chava
SqlConnection con;
protected void Page_Load(object sender, EventArgs e)
{
Get_Conn("TSQL");
//Get_Conn("ACCESS");
//Get_Conn("ORACLE");
}
protected void Get_Conn(string con_condition_Str)
{
switch (con_condition_Str)
{
case ("ACCESS"):
//SET CON = access constring
break;
case ("TSQL"):
// SET CON = SQL SERVER constring
break;
case ("ORACLE"):
// SET CON = ORACLE constring
break;
}
}
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / 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 |
What providers does Ado.net uses?
What are the steps you will take to improve performance? Will you use dataset or datareader?
What is the purpose of using adodb?
How to add an aggregate column?
How xml files and be read and write using dataset ?
how Sequence to connect and retrieve data from database using dataset?
Why do we serialize data?
Which control of the BindingNavigator returns the current position within the data source?
Explain the various objects in dataset.
Give few examples of datareader that is used in different dataproviders.
What is data control techniques?
What is ado recordset?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)