how to do it?
-
if some clients accessing s/w with MYSQL as data base and some with oracle.(interface same but backend storage is different). how do it in asp.net? what are the methods i must use it to implement above concept? thank you
vijaya
-
if some clients accessing s/w with MYSQL as data base and some with oracle.(interface same but backend storage is different). how do it in asp.net? what are the methods i must use it to implement above concept? thank you
vijaya
You need to create different dataaccess layers to do this. Because MySQL is conneted with ODBC and Oracle using OracleClient. So you need to create seperate DAL and call the appropriate one.
-
if some clients accessing s/w with MYSQL as data base and some with oracle.(interface same but backend storage is different). how do it in asp.net? what are the methods i must use it to implement above concept? thank you
vijaya
You may use like that. Classes and Interface
interface IDatabase{ public int Execute(String sqlStmt); } public class MySQLDatabase() : IDatabase{ public int Execute(String sqlStmt){ //Do something wtih MySQL datbase } } public class OracleDatabase() : IDatabase{ public int Execute(String sqlStmt){ //Do something wtih Oracle datbase } } public class DatabaseProxy(){ IDatabase iDb; DatabaseProxy(){ if(config.ReadDbSetting() == "1") iDb = new MySQLDatabase(); else iDb = new OracleDatabase(); } public static int Execute(String sqlStmt){ return iDb.Execute(sqlStmt); } }
ASP.NET Code-behindDatabaseProxy.Execute("Statemet");
P.S: you may need to change some syntax since I typed it just like that.. I would like to suggest you to check the sourcecode of this opensouce multi-database forums "http://dnfbb.sourceforge.net/"Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
-
You may use like that. Classes and Interface
interface IDatabase{ public int Execute(String sqlStmt); } public class MySQLDatabase() : IDatabase{ public int Execute(String sqlStmt){ //Do something wtih MySQL datbase } } public class OracleDatabase() : IDatabase{ public int Execute(String sqlStmt){ //Do something wtih Oracle datbase } } public class DatabaseProxy(){ IDatabase iDb; DatabaseProxy(){ if(config.ReadDbSetting() == "1") iDb = new MySQLDatabase(); else iDb = new OracleDatabase(); } public static int Execute(String sqlStmt){ return iDb.Execute(sqlStmt); } }
ASP.NET Code-behindDatabaseProxy.Execute("Statemet");
P.S: you may need to change some syntax since I typed it just like that.. I would like to suggest you to check the sourcecode of this opensouce multi-database forums "http://dnfbb.sourceforge.net/"Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
If he's using .NET 2, then this is unnecessary. .NET 2 provides a better abstraction layer which can remove a lot of these issues. Take a look at things like the DbConnection, DbCommand classes to see what I mean.
Please visit http://www.readytogiveup.com/ and do something special today. Deja View - the feeling that you've seen this post before.
-
If he's using .NET 2, then this is unnecessary. .NET 2 provides a better abstraction layer which can remove a lot of these issues. Take a look at things like the DbConnection, DbCommand classes to see what I mean.
Please visit http://www.readytogiveup.com/ and do something special today. Deja View - the feeling that you've seen this post before.
-
This might get you started:
DbProviderFactory factory = DbProviderFactories.GetFactory("MySample.Oracle"); DbConnection conn = factory.CreateConnection(); conn.ConnectionString = "..."; conn.Open(); DbCommand cmd = conn.CreateCommand(); cmd.CommandText = "SELECT * FROM MyTable"; DbDataReader rdr = cmd.ExecuteReader();
and so on...
Please visit http://www.readytogiveup.com/ and do something special today. Deja View - the feeling that you've seen this post before.