0 Hi Kamal,
Create one Interface to access for different databases. The below steps help you to maintain universal DAL.
Steps:
1. Create Interface with the name IDataAccess
Public Interface IDataAccess
{
void DbConnection();
DataTable GetAllData();
bool InsertData();
bool UpdateData();
bool DeleteData();
}
2. Implement the interface for Sql database access with the class name DataAcessSql.cs and implement all the methods of IDataAccess interface
Public class DataAccessSql:IDataAccess
{
Public void DbConnection()
{
// write the code for Sql connection
}
Public DataTable GetAllData()
{
// write the code to get data from Sql database.
}
Public bool InsertData()
{
// write the code for inserting data into Sql database.
}
Public bool UpdateData()
{
// write the code for updating data into Sql database.
}
Public bool DeleteData()
{
// write the code for deleting data from Sql database.
}
}
3. Implement the interface for Oracle database access with the class name DataAcessOracle.cs and implement all the methods of IDataAccess interface
Public class DataAccessOracle:IDataAccess
{
Public void DbConnection()
{
// write the code for Oracle database connection
}
Public DataTable GetAllData()
{
// write the code to get data from Oracle database.
}
Public bool InsertData()
{
// write the code for inserting data into Oracle database.
}
Public bool UpdateData()
{
// write the code for updating data into Oracle database.
}
Public bool DeleteData()
{
// write the code for deleting data from Oracle database.
}
}
In this way we can maintain universal DA. We cannot get any conflicts by using different databases.
I hope this will help you to matain universal DAL, let me know if you have any queries on this.