C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




How Design patterns make .net 2.0 a miracle


Posted Date: 11 Aug 2006    Resource Type: Articles    Category: Web Applications
Author: Ved PrakashMember Level: Bronze    
Rating: Points: 2



Design Patterns in .Net





Writing Generic data access code



Summary


Till .net 1.1 we were able to use single provider at a time means we were not able to change providers run time.Now with the help of provider pattern .net has given us the gift of system.data.common namespace .with the help of that we can create the connection object run time .we can use different providers for Oracle ,sql server ,MS Access or xml what ever we want . as follows

string factory = WebConfigurationManager.AppSettings["factory"];
DbProviderFactory provider = DbProviderFactories.GetFactory(factory);
DbConnection connection = provider.CreateConnection();
connection.ConnectionString=WebConfigurationManager.ConnectionStrings"ProductCatalog"].ConnectionString;
DbCommand command = provider.CreateCommand();
command.CommandText = WebConfigurationManager.AppSettings["ProductQuery"];
command.Connection = connection;
connection.Open();
DbDataReader reader = command.ExecuteReader();

In the above article I have used a word factory in Appsetting which is being given in web config file as a tag. for more detail wait for my next article




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Difference Between usercontrol and custom control in .net
Previous Resource: Highlight Searchtext in Datagrid or in a Page
Return to Discussion Resource Index
Post New Resource
Category: Web Applications


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use