FillDataset replacement when upgrading from 2.0 to 5.0

Topics: Data Access Application Block
Aug 19, 2011 at 1:29 PM


We are intensively using the Microsoft.ApplicationBlocks.Data.SqlHelper.FillDataset in the DAAB 2.0. The amazing feature with this method is that it takes a "Dim pa() As SqlClient.SqlParameter" parameter and the SqlParameter´s can be created with following New(parameterName As String, value As Object):
  parameterName: The name of the parameter to map.
  value: An System.Object that is the value of the System.Data.SqlClient.SqlParameter.

As you can see no DBType is needed as parameter.

In 5.0 equivalent method is used: .AddInParameter(insertCommand, "name", DbType.String, "Name", DataRowVersion.Current)

In AddInParameter the DBType is needed and hardcoded. It is easy to code wrong and it is not nice considering code maintenance.

Do you have any comment on how to update data using 5.0 without stating dbtype excplicitly?

Best regards,
Benjamin, CDAB

Aug 22, 2011 at 2:40 AM

Hi Benjamin,

That methodology is called Parameter Discovery. It is still on the Enterprise Library 5.0. Here is a sample code (in C#) on how to achieve that:

string sql = "UpdateProduct";
DbCommand cmd = db.GetStoredProcCommand(sql, 11, "Queso Cabrales", 4, 25);

 For more details, kindly refer here


Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
Contact Us