BUG: An error message occurs when you try to change the value of the child key column in the DataSet object (316146)



The information in this article applies to:

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

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

SYMPTOMS

If you simulate a join query by using two DataTable objects (a DataRelation and an expression-based column that references the relation), you may receive the following error message if you try to change the value of the child key column in the DataSet object:
System.Data.VersionNotFoundException: There is no Proposed data to access.

RESOLUTION

There is no current workaround for this problem. Either do not use an expression-based column, or use the data in a read-only situation.

STATUS

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

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create a new Visual Basic .NET console application.
  2. At the top of the code window, add the following code:
    Imports System.Data.OleDb
  3. Paste the following code into Module1:
    Sub Main()
       Dim strConn, strSQL As String
       strConn = "Provider=SQLOLEDB;Data Source=YourSQLServer;" & _
         "Initial Catalog=Northwind;User ID=YourUserID;Password=YourPassword;"
       Dim cn As New OleDbConnection(strConn)
       cn.Open()
       ResetOrder(cn)
    
       strSQL = "SELECT OrderID, ProductID, Quantity, UnitPrice " & _
           "FROM [Order Details] WHERE OrderID = 10503 " & _
           "ORDER BY ProductID"
       Dim daOrderDetails As New OleDbDataAdapter(strSQL, strConn)
       strSQL = "SELECT ProductID, ProductName FROM Products"
       Dim daProducts As New OleDbDataAdapter(strSQL, strConn)
    
       Dim ds As New DataSet()
       daProducts.FillSchema(ds, SchemaType.Source, "Products")
       daOrderDetails.FillSchema(ds, SchemaType.Source, "Order Details")
       ds.Relations.Add("ProductsOrderDetails", _
          ds.Tables("Products").Columns("ProductID"), _
          ds.Tables("Order Details").Columns("ProductID"))
       ds.Tables("Order Details").Columns.Add("ProductName", GetType(String), _   
          "Parent.ProductName")
       daProducts.Fill(ds, "Products")
       daOrderDetails.Fill(ds, "Order Details")
    
       DisplayOrder(ds.Tables("Order Details"))
       Dim rowDetail, rowProduct As DataRow
       rowProduct = ds.Tables("Products").Rows.Find(1)
       rowDetail = ds.Tables("Order Details").Rows(0)
       Try
          ds.Tables("Order Details").Rows(0)("ProductID") = 1
       Catch ex As Exception
          Console.WriteLine(ex.ToString)
          Console.ReadLine()
          Exit Sub
       End Try
    
       DisplayOrder(ds.Tables("Order Details"))
    
       Dim cbOrderDetails As New OleDbCommandBuilder(daOrderDetails)
       cbOrderDetails.QuotePrefix = "["
       cbOrderDetails.QuoteSuffix = "]"
       daOrderDetails.Update(ds.Tables("Order Details"))
    
       ds.Tables("Order Details").Clear()
       daOrderDetails.Fill(ds.Tables("Order Details"))
       DisplayOrder(ds.Tables("Order Details"))
    
       cn.Close()
    End Sub
    
    Private Sub DisplayOrder(ByVal tbl As DataTable)
       Dim row As DataRow
       For Each row In tbl.Rows
          Console.WriteLine(row("OrderID") & " - " & row("ProductName") & _ 
           " - " & row("ProductID"))
       Next
    End Sub
    
    Private Sub ResetOrder(ByVal cn As OleDbConnection)
       Dim strSQL As String
       strSQL = "DELETE FROM [Order Details] WHERE OrderID = 10503;" & _
          "INSERT INTO [Order Details] " & _
          "    (OrderID, ProductID, Quantity, UnitPrice) " & _
          "    VALUES (10503, 14, 70, 23.25);" & _
          "INSERT INTO [Order Details] " & _
          "    (OrderID, ProductID, Quantity, UnitPrice) " & _
          "    VALUES (10503, 65, 20, 21.05)"
          Dim cmd As OleDbCommand = cn.CreateCommand
          cmd.CommandText = strSQL
          cmd.ExecuteNonQuery()
    End Sub
    					
  4. Modify the connection string (strConn) as necessary for your environment.
  5. Press F5 to run and to compile the application. You receive the error message in the "Symptoms" section.

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