Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to do it?

how to do it?

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netmysqloracletutorial
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kvijayajyothy
    wrote on last edited by
    #1

    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

    N M 2 Replies Last reply
    0
    • K kvijayajyothy

      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

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      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.


      My Website | Ask smart questions

      1 Reply Last reply
      0
      • K kvijayajyothy

        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

        M Offline
        M Offline
        Michael Sync
        wrote on last edited by
        #3

        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-behind DatabaseProxy.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)

        P 1 Reply Last reply
        0
        • M Michael Sync

          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-behind DatabaseProxy.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)

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          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.

          N 1 Reply Last reply
          0
          • P Pete OHanlon

            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.

            N Offline
            N Offline
            N a v a n e e t h
            wrote on last edited by
            #5

            Excellent. You got 5 from me. But do you have any examples ?


            My Website | Ask smart questions

            P 1 Reply Last reply
            0
            • N N a v a n e e t h

              Excellent. You got 5 from me. But do you have any examples ?


              My Website | Ask smart questions

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups