Introduction to Ado.net

Vuyiswamb
Posted by in ADO.NET category on for Beginner level | Views : 12133 red flag

To my surprise, there are still software development houses that still initiate Development using languages like VB6 and obviously using ADO. In most of the time when someone has a Problem about ADO, I fail to referrer them to an article about Introduction to ADO.NET. So I thought I should write one that will tell them how great it is to build Applications in .NET and ADO.NET is the best thing that has ever happened to Database Programming. In this Article, we are going to introduce those who are still experiencing ADO Problems to .Net.
Introduction
To my Surprise there are still vb6 Guru who are not willing to let go of VB6. Well talking from experience, I have to suffer the results of it in the future, because of the saying that goes by “If its working, Do not Fix it”, I recently had a vb6 Application, obviously not written by me.I don’t associate myself with those type of applications by trying to fix a vb6 code. The Application will break; you will get Sql timeouts and all the errors you can imagine.

ADO.NET presents us with what I call “Resource Saver”, that means your application does not always need to be connected to the SQL Server to work. Look at it as disconnected recordset. that means your application will just request the Data and Store them in the Cache and Disconnect from the SQL Server and the user will continue to work, when done and needs to update the data, then the connection will be established with the server and the Update will be done and again there will be a disconnection from the server to save resources. See that’s easy and its saving a lot of resources.

The Story Continues

For the Past Decades the way Applications access data has changed repeatedly. Programmers moved from Simple Client Applications that use local Database’s to a distributed system that uses a centralized databases. If you worked with Languages like vb6 or java you will know that there was something like ADO, ODBC, RDO and RDS. Well they had their good times and I personally preferred ADO, because there was nothing that looked better than it. When Microsoft introduced ADO.NET, I thought I was dreaming I ran straight to the Bookstore and Look a Book in ADO.NET; it was like a newspaper to me. “Was it true that Microsoft created disconnected recordset technology?” Well it was true. In .NET we have ADO.NET.

ADO.NET

Ado.net consists of classes that allow a .NET application to connect to the data source, executes commands and manage disconnected data. One of the key Differences between ADO.NET and other database technologies is how it deals with Challenge with different data sources, that means, the code you use to connect to an SQL Database will not differ that much to the one connecting to an Oracle Database. In many previous database technologies like ADO, a programmer had to use generic set of objects, no matter what the underlying data source is. That means if you have a Data layer, your Dal(Data Access Layer) Class can be used on Both Oracle and SQL, so there is nothing to change, but now in .NET it’s a Different Story, Ado.net uses provider model, that means I cannot connect to a SQL database with a OleDb Provider or Oracle Provider. What are providers? Data Providers as a set of ADO.NET Classes that allows you to access certain databases execute commands, retrieve data and more. So that means in order to connect to the SQL database you need to have a Provider of “SQltype” SQLClient. The Data Provider is a Middle man or a Bridge between your Database and your Application. The Data Provider is made up of the Following Classes.

 

Connection – we use this to establish a connection to the Data Source, that’s where you will pass your constructor with a connection string.

 

Command - We use the command object to execute the commands and storedprocedures.

 

Datareader - A datareader is a read only, forward only access to the data retrieved from a query and its normally used on read only data, or to Populate Comboboxes and more.

 

DataAdapter - This object performs two tasks, we use it to fill the Dataset (Disconnected Recordsets as I call it, but this one is powerful it carries a tables, that means a Dataset can contain many tables.)And another thing you can do with the adapter is to make changes to the Data, by first Connecting to the Datasource and making Changes.

 

Each Data provider has a specific implementation of Connection, Command and Adapter. That means if you need to a SQl database, you should use SQLConnection Class.

Conclusion

My Advice to those who are not yet in .NET is that, you buy a Book in .NET. well I have some Good Books you can get from Apress by Matthew MacDonald and Mario Szpuszta. Get some online training at www.itfunda.com. But for now its time for you to rush to a Book store and move to .NET

 

That was short J

 

 

Thank you

Page copy protected against web site content infringement by Copyscape

About the Author

Vuyiswamb
Full Name: Vuyiswa Maseko
Member Level: NotApplicable
Member Status: Member,MVP,Administrator
Member Since: 7/6/2008 11:50:44 PM
Country: South Africa
Thank you for posting at Dotnetfunda [Administrator]
http://www.Dotnetfunda.com
Vuyiswa Junius Maseko is a Founder of Vimalsoft (Pty) Ltd (http://www.vimalsoft.com/) and a forum moderator at www.DotnetFunda. Vuyiswa has been developing for 16 years now. his major strength are C# 1.1,2.0,3.0,3.5,4.0,4.5 and vb.net and sql and his interest were in asp.net, c#, Silverlight,wpf,wcf, wwf and now his interests are in Kinect for Windows,Unity 3D. He has been using .net since the beta version of it. Vuyiswa believes that Kinect and Hololen is the next generation of computing.Thanks to people like Chris Maunder (codeproject), Colin Angus Mackay (codeproject), Dave Kreskowiak (Codeproject), Sheo Narayan (.Netfunda),Rajesh Kumar(Microsoft) They have made vuyiswa what he is today.

Login to vote for this post.

Comments or Responses

Posted by: Raja on: 7/22/2008
Thanks for a great introduction about ADO.NET. For those who are looking for free ADO.NET Ebooks may download it from http://www.free-ebooks-download.org/free-ebook/dotnet/ADO.NET/

Thanks and keep it up Vuyiswa.
Posted by: Bhupentiwari on: 6/26/2012 | Points: 25
good articles

Login to post response

Comment using Facebook(Author doesn't get notification)