BUG: You cannot create calculated expressions on DataSet objects in the Schema Designer (311522)



The information in this article applies to:

  • Microsoft ADO.NET (included with the .NET Framework)
  • Microsoft .NET Framework

This article was previously published under Q311522
This article refers to the following Microsoft .NET Framework Class Library namespace:
  • System.Data

SYMPTOMS

  • When you add an instance of a calculated expression in the Schema Designer and you preview that expression, the following error message appears and you are not allowed to create the instance.
    Exception has been thrown by the target of an invocation
    -or-

  • When you modify a DataSet object to add a calculated expression, the form will not load and the Form Designer will display the following error message:
    An exception occurred while trying to create an instance of DataSet
    If this occurs, you must fix the problem manually before you can see the form again.

CAUSE

The DataSet tries to use rows that have not yet been defined to create the expression.

RESOLUTION

To work around this problem, create the expressions after you instantiate the DataSet. After you create the tables and rows in the DataSet constructor, the expressions will be accepted. For example:
Dim objDS as new DataSet1
objDS.myTable.AvgColumn.Expression = "avg(Child.Values)"
				

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

Modification Type:MinorLast Reviewed:3/9/2006
Keywords:kbtshoot kberrmsg kbbug kbMiscTools kbpending kbreadme kbSystemData KB311522 kbAudDeveloper