Click here to Skip to main content
15,889,890 members
Please Sign up or sign in to vote.
3.67/5 (3 votes)
Hi all,

I want to create N-tier architecture with two different datasources in asp.net.

My project would be running with asp.net 3.5 framework and backend are Oracle and Sql Server 2005.

Whenever project would be install in server then it will decide that it will running Oracle or Sql Server 2005. These setting(Database type [<add key="DBType" value="Oracle" />]) would be read from web.config file.

I don't want to use NHibernate.


Please help me.


Thanks in Advance.
Gautam
Posted
Updated 3-Jul-11 20:46pm
v3

What does NHibernate have to do with anything ? As these are two databases, all you need to do, is write stored procs in each database that take the same paremeters and return the same values, and let the user specify a connection string in the web.config, to whatever DB type they prefer. You can then use the generic classes, or if you prefer, you can write two data layers so you can use SQL Server and Oracle specific classes, but I don't see what benefit that would be, especially. In that case, you'd need some sort of flag to tell the system which one to use.
 
Share this answer
 
v2
Comments
gautam1208 4-Jul-11 3:06am    
Thanks dear.. for your quick reply.
My problem is that I cannot use stored procs because of permission in hosting server.
Can u provide me some dummy code with n tier architecture and sql query
You will need to handle this in the DAL layer. However, using Oracle and SQL Server together within the same app is never an easy thing to do. Be especially vary of handling large objects and also date formatting when using them together.
 
Share this answer
 
You can use Data Access Application Block provided by Microsoft. I have used this for one application which runs on Oracle or SQL server. To know more about this visit

http://msdn.microsoft.com/en-us/magazine/cc163766.aspx[^]
 
Share this answer
 
Comments
gautam1208 4-Jul-11 3:10am    
Thanks for quick response.
I am going to know more about that link.
Thanks
The PetShop sample application has addressed this situation in a very intutive way...
You can down load the project from the following link

http://download.microsoft.com/download/8/0/1/801ff297-aea6-46b9-8e11-810df5df1032/Microsoft%20.NET%20Pet%20Shop%204.0.msi[^]

and a detailed instruction can be found here

http://msdn.microsoft.com/en-us/library/Aa479070[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900