Stories Tagged with 'ADO.NET'


What ADO.NET 2.0 Book Do I Recommend?

Url: http://www.amazon.com/exec/obidos/ASIN/15905951...

Since my announcement last year that there would not be an update to my book ("Pragmatic ADO.NET") to show the changes in ADO.NET 2.0, I have been asked what book I would recommend. I have scoured the ADO.NET 2.0 books and finally have a firm recommendation:

My New Article on NHibernate is Up!

Url: http://www.devsource.com/article2/0,1895,192569...

Slow Transactions with System.Transactions and SQL Server 2000

Url: http://blogs.msdn.com/florinlazar/archive/2005/...

Thanks to Bill Booth via the Windows Off Topic Mailing List, I was concerned that the DTC was being used for intra-database transactions with SQL Server 2000.  I was looking at timing and using System.Transactions with SQL 2000 is through the roof slower than using traditional client-side transactions.  Interestingly SQL 2005 doesn't have this limitation.  Lazar Florin has a great blog post that explains what is happening here (found here).

OR Mappers, Code Generators and Business Object Frameworks

I am currently doing a bunch of evaluations on OR Mappers, Code Gen and Business Object Frameworks for my new book.  If anyone knows about anything great that might go unnoticed, please drop a comment or send me an email!

Thanks!

Surprise! A New Review of My Book

Url: http://dotnet.sys-con.com/read/105634.htm

I was surprised to learn that someone just finished a review of my ADO.NET 1.x book.  Wow.  If you interested, follow the link!

Upgrading Typed DataSets in Visual Studio 2005

Url: http://www.devsource.com/article2/0,1895,183430...

TableAdapters, DataAdapters and Migrated Typed DataSets

In Visual Studio 2005, when you create a Typed DataSet, it automatically creates TableAdapters for you.  These are interesting objects that use a DataAdapter internally to make a more cohesive data access layer.  It will certainly help the RAD developers get started.  I am not so sure about how they will work long-term though. 

One of the more interesting things that these new Typed DataSets do is store a link to connection information in the Typed DataSet.  These seems to be used for the TableAdapters to do their open's with.  Problem seems to be that if you migrate a Typed DataSet from 1.1, there is no way to insert this connection information.  Even if you do, the designer in Beta 2 doesn't allow you to attach TableAdapters to your existing Typed DataSet.  This means that if you want to use TableAdapters you will need to re-do your Typed DataSets entirely.

Well Thought Out Blog on Typed DataSets

Url: http://jelle.druyts.net/PermaLink.aspx?guid=616...

Not sure how I missed this before.  I was very impressed by this discussion of the issues around Typed DataSets.  Yeah, sure he agrees with most of my opinions...but I like hearing that as well as dissenting opinions.

Oracle 10g Supporting the CLR?

Url: http://news.com.com/Oracle+readies+second+grid+...

DataSet.ClearBeforeFill? (UPDATED!)

In previous builds, the DataSet had a property on them that said whether they should clear the DataSet whenever it is Filled by a DataAdapter.  It seems to be missing in the latest builds.  I actually prefer this because the nature of DataSets (and often overlooked) is that successive DataAdapter.Fill's will allow a DataSet to grow incrementally.  New rows will be added, and existing rows will be updated (unless it is dirty, then you would get an exception). 

Maybe my ranting to Steve Lasker paid off in a small way. 

Why I Don't Like the Data Access Block (in the Enterprise library, circa Jan 05)

Url: http://wildermuth.com/content.aspx?id=rantview&...

After looking over the latest Data Access Block, i'll say it is better.  But I still have my gripes:

Why I Don't Like the Data Access Block (v2)

Url: http://www.microsoft.com/downloads/details.aspx...

I have talked with many people over the last few years about my issues with the the Data Access Block, but it seems I've never enumerated my issues in 'print'.  Here they are.  If this has been fixed in the EL version the Data Access Block then yippie!

Raise your hand if you know what DataAdapter.TableMappings is for...

Url: http://msdn.microsoft.com/library/default.asp?u...

I seem to be getting a lot of questions and reviewing a lot of code that isn't use TableMappings and I wonder why.  For example I see this occassionally:

New Oracle .NET Technology Center

Url: http://www.oracle.com/technology/tech/dotnet/in...

Rocky and I Agree on n-Tier Development

Url: http://www.lhotka.net/WeBlog/PermaLink.aspx?gui...

Is Data Access Really This Hard?

I've been spending some time lately reviewing how companies are doing data access in .NET.  When I look at how most of them have crufted up solutions, I am amazed.  The model that Microsoft supports seems so obvious to me, but I am neck deep in it.  I'd like to hear from my readers their specific experience with creating data access in .NET; with an eye to why or why not use COM+ for transactions; Typed DataSet or DataReaders; Business Objects or Messages.  I am trying to understand where the community is.

Thanks in advance...

DataAdapters and Component Surfaces (or why I love using the toolset)

I always forget this blog this, but when I am doing a database project using Typed DataSets, I almost always use a Component Surface to build my DataAdapters interactively.  For example:

Here I add a component to my project:

In Response to Sahil Malik's Null problem

Url: http://dotnetjunkies.com/WebLog/sahilmalik/arch...

In response to your rant about the inelegance of the CLR's null implementation:

Rocky Lhotka on DataSets and Web Services and why I think he's wrong...

Url: http://www.lhotka.net/WeBlog/CommentView.aspx?g...

After reading Rocky's blog about DataSets and Web Services, I am afraid that he is falling into the same trap that other's have (including the emminently qualified Tim Ewald) with respect to DataSets.  DataSets work well in Web Services but not by default.  As I mentioned in:

DataSet Updater Helper Method

For some time now I've been pushing the idea of doing DataSet updates using DataAdapters that use a 1-to-1 relationship between DataAdapter and logical data elements (e.g. Tables or Stored Procedures usually).  This is especially true when you are dealing with related tables in DataSets (the sweet spot for DataSets IMHO).  I've continually forgotten to post this code that I use to do these updates.  The idea of this code is for the user to provide arrays of Tables and DataAdapters that imply the order of the updates.  For example

// Array of DataTables from a Typed DataSet
DataTable[] updateTables = new DataTable[] {
                          dataSet.Customers,
                          dataSet.Orders,
                          dataSet.OrderDetails,
                          dataSet.Products
                                           };
// Array of DataAdapters
DataAdapter[] updateAdapters = new DataAdapter[] {
                          customerAdapter,
                          orderAdapter,
                          orderDetailAdapter,
                          productAdapter
                                                 };
// Call the Update Method
UpdateDataSet(updateTables, updateAdapters);

This implies the order so that the helper function can do the right thing which is to delete bottom up, and insert/update top down:

Hoping that Microsoft Makes the ADO.NET PowerPack Obsolete

ADO.NET Powertoys and GotDotNet Workspace

Url: http://wildermuth.com/powertoys

Data Part 2: n-Tier...Gone Tomorrow

Recently I was talking with Rocky Lhotka and he said something interesting:

Just when we got good at Client-Server, they switched things and had us doing n-Tier applications.  Just when we got good at n-Tier development, internet applications took off.

Data Part 1: Business Objects, Messages and DataSets...

I've had time lately to think about the nature of data in development lately.  I've been talking with Rocky Lhotka and Michael Earls about it (as well as number of others) about the issues with dealing with data in applications. 

The first camp is all about writing Business Objects.  In this camp, you write classes that encapsulate the data, the data access and business rules about that data.  This camp was the way to do it for years now.  It proliferated in the Client-Server and n-Tier architecture camps. 

Connections, Command and Transactions...oh my!

I was taking a refresher MCSD test today to get ready to take one of the tests and came upon a question that is wrong.  But it does infer that there is some confusion about how transactions are propogated to commands...or may be evidence that it is a bug.  For example:

SqlConnection conn = null;
SqlTransaction tx = null;
try
{
  // Create a new Connection
  conn = new SqlConnection("Server=.;Database=Northwind;Integrated Security=true;");

  // Open the Connection
  conn.Open();

  // Start a Transaction and create a new Command
  tx = conn.BeginTransaction();
  using (SqlCommand cmd = new SqlCommand())
  {
    // Set the Connection to the command
    cmd.Connection = conn;

    // NOTE: I do not explicitly set the TX to the Command
    //cmd.Transaction = tx;

    // Insert new values and execute it 
    // (within the transaction)
    cmd.CommandText = @"INSERT INTO Customers (CustomerID, CompanyName) 
                        VALUES ('ZZZZY', 'My New Company');";
    cmd.ExecuteNonQuery();

    // Insert new values, but the table name is wrong
    cmd.CommandText = @"INSERT INTO Companies (CompanyID) VALUES('ANother Company')";
    cmd.ExecuteNonQuery();

    // We should never get here since the query is wrong
    tx.Commit();
  }
}
catch (Exception ex)
{
  // Rollback the tx if error'd
  if (tx != null) tx.Rollback();
}
finally
{
  tx.Dispose();
  // Close the connection just in case
  if (conn != null)
  {
    conn.Close();
    conn.Dispose();
  }
}

This code fails because I do not explicitly set the transaction to the command.  Unfortuately, you must set the connection and the transaction.  This seems like a bug because you cannot execute a command on the connection (that has an pending transaction) without throwing an error. 

Shawn
Shawn Wildermuth
Author, Teacher, and Coach




My Courses

Wilder Minds Training
Vue.js by Example (New Lower Price)
Bootstrap 4 by Example (New Lower Price)
Intro to Font Awesome 5 (Free Course)
Pluralsight
Building an API with ASP.NET Core (New Course)
Building a Web App with ASP.NET Core, MVC6, EF Core, Bootstrap and Angular (updated for 2.2)
Less: Getting Started (New)
Using Visual Studio Code for ASP.NET Core Projects
Implementing ASP.NET Web API

Application Name WilderBlog Environment Name Production
Application Ver v4.0.30319 Runtime Framework x86
App Path D:\home\site\wwwroot\ Runtime Version .NET Core 4.6.27514.02
Operating System Microsoft Windows 10.0.14393 Runtime Arch X86