FIX: DataGrid Error Deleting Last Row From OSP Provider Data

ID: Q223082


The information in this article applies to:


SYMPTOMS

If an OLE DB Simple Provider (OSP) is the bound DataSource for a Data Grid and an attempt is made to delete all the rows in the Data Grid, the following error is generated on the deletion of the last row:

Microsoft DataGrid Control: Error occurred while trying to delete record.


STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

This bug was corrected in Visual Studio 6.0 Service Pack 3. For more information about Visual Studio service packs, please see the following articles in the Microsoft Knowledge Base:

Q194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why

Q194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed


MORE INFORMATION

Steps to Reproduce Behavior

  1. Obtain the following two files from the Data Access SDK:

    - ospsampb.dll

    - sampleosp_vb.reg
    NOTE: The Data Access SDK can be downloaded from the following location:

    http://www.microsoft.com/data/download.htm)


  2. Use Regsvr32 to register the ospsampb.dll.


  3. Double-click the sampleops_vb.reg file to properly register ospsampb.dll as a OLE DB Simple Provider.


  4. Start Visual Basic 6.0 and create a Standard EXE project. Form1 is created by default.


  5. Set the following project references:


  6. - Microsoft ActiveX Data Objects

    - Microsoft Data Adapter Library

    - Sample OLE DB Simple Provider (Visual Basic 98)
  7. Add the following control to the default form and set its AllowDelete property to True:


  8. - Microsoft DataGrid Control (OLE DB)
  9. Paste the following code into the default form:


  10. 
    Dim da As New DataAdapter
    Dim ds As New MyDataSource
    
    Set da.Object = ds
    DataGrid1.DataMember = App.Path & "\Customer.txt"
    Set DataGrid1.DataSource = da 
  11. Save the project.


  12. Paste the following text into Notepad.exe:


  13. 5;2
    CustomerID;CompanyName;
    WANDK;Die Wandernde Kuh;
    WARTH;Wartian Herkku;
    WELLI;Wellington Importadora;
    WHITC;White Clover Markets;
    WILMK;Wilman Kala;
  14. Save the file as "Customer.txt" in the same directory as the Visual Basic project created above.


  15. Run the Project, click on a row's Row-Indicator (the left-most column) to select the entire row, and press the DELETE key to delete the row.


  16. Repeat the step above for each row in the grid.


© Microsoft Corporation 1999, All Rights Reserved.
Contributions by Matthew Hofacker, Microsoft Corporation

Additional query words:


Keywords          : kbservicepack kbCtrl kbDataBinding kbOLEDB kbVBp600bug kbVS600sp2 kbVS600SP1 kbVS600sp3fix kbGrpVBDB 
Version           : WINDOWS:6.0
Platform          : WINDOWS 
Issue type        : kbbug 

Last Reviewed: May 20, 1999