Databases are vital to the world of programming. In my early days, I shivered at the D word, but now practically every application needs somewhere to store information about employees , customers, orders, whoever, whatever.
In the past, we ve had DAO, RDO, and ADO, an alphabet soup of acronyms representing technologies that allow us to access databases in code. With the launch of the .NET Framework, we re introduced to ADO.NET, the all-new method of plugging into all our favorite database formats ”and there s not a Recordset in sight.
How does it work? You have a bundle of objects in the System.Data namespace: one set for accessing OLE databases such as Oracle or Access, and another finetuned for accessing SQL Server ( plug plug ).
The concept of the aging ADO Recordset is replaced with the ADO.NET DataSet, which is essentially a bundle of tables in one object, with possible relationships between them. You also have a Command object specific to both SQL Server and OLE databases, allowing you to get close to your data and execute SQL statements directly. These Command objects can work with DataReader objects, which are like forward-only, read-only Recordsets.
Confused? You will be.
In fact, if you haven t touched ADO.NET before, I m willing to bet that you ll find the Essentials portion of this chapter scarier than Developer Secrets . The trick is, however, not to be overwhelmed simply curious .
What will we learn in this chapter? As ever, we begin with the basics to either refresh your knowledge or get you up and running as quickly as possible. Then, we re going to dive straight into those amazing secrets.
We ll discover how to send our data straight to the user as an Excel spreadsheet with just a couple of lines of code (Excel not required!). You ll find out how to quickly create editable feature-full data grids for both Windows and the Web. We ll even get the lowdown on all those little-known developer tricks, such as paging, sorting, confirming deletes, color coding, and much, much more.
Ready to rumble? Read on!