Microsoft Knowledge Base Email Alertz

(831222) - The Fill method of the DataAdapter object of the OLE DB managed provider may not work correctly when you apply an ADO Recordset object with filter criteria, and you use the Recordset object to populate the Dataset object. You set the criteria for the...

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 831222 - Last Review: November 28, 2007 - Revision: 2.2

FIX: The Fill method of the OleDBDataAdapter object fails when the Recordset object has a filter

Caution ADO and ADO MD have not been fully tested in a Microsoft .NET Framework environment. They may cause intermittent issues, especially in service-based applications or in multithreaded applications. The techniques that are discussed in this article should only be used as a temporary measure during migration to ADO.NET. You should only use these techniques after you have conducted complete testing to make sure that there are no compatibility issues. Any issues that are caused by using ADO or ADO MD in this manner are unsupported. For more information, see the following article in the Microsoft Knowledge Base:
840667   (http://kbalertz.com/Feedback.aspx?kbNumber=840667/ ) You receive unexpected errors when using ADO and ADO MD in a .NET Framework application

On This Page

SYMPTOMS

The Fill method of the DataAdapter object of the OLE DB managed provider may not work correctly when you apply an ADO Recordset object with filter criteria, and you use the Recordset object to populate the Dataset object.

You set the criteria for the Recordset object. When you open the Recordset object by using the filter criteria, and you try to fill the records in the Dataset object by using the Fill method of the OleDbDataAdapter object, the action fails, and you receive the following exception error message:
An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in system.data.dll

Additional information: Exception has been thrown by the target of an invocation.

RESOLUTION

A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that this article describes. Apply it only to systems that are experiencing this specific problem.

To resolve this problem, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:
http://support.microsoft.com/contactus/?ws=support (http://support.microsoft.com/contactus/?ws=support)
Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question. The hotfix version of this has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.
 

  Date           Time  Version    Size       File name     
   --------------------------------------------------------
   10-Nov-2003 17:46   1.1.4322.968   1,294,336   system.data.dll

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section of this article.

MORE INFORMATION

Steps to reproduce the behavior

  1. Start Microsoft Visual Studio .NET 2003.
  2. On the File menu, point to New, and then click Project.
  3. Under Project Types, click Visual Basic Projects, and then click Windows Application under Templates.
  4. Name the project SampleOleDbDataAdapter.

    NoteSampleOleDbDataAdapter is a placeholder for the name of the application.
  5. Add a Button control to Form1.
  6. Add a reference to adodb. To add this reference, follow these steps:
    1. In Solution Explorer, right-click References.
    2. Click Add Reference.
    3. On the .NET tab, click adodb, and then click Select.
    4. Click OK.
  7. Add the following code at the top of the code window:
    Imports System.Data.OleDb
  8. In the click event of the Button1 control, add the following code:
    Dim ADOCn As New ADODB.Connection
    Dim ADORs As New ADODB.Recordset
    'Connect Database Server 
    
    ADOCn.Open("Provider=SQLOLEDB;Data Source=servername;Initial Catalog=Northwind;Integrated Security=SSPI")
    'Do a simple filter criteria
    ADORs.Filter = "CustomerID = 'ALFKI'"
    'Open the Recordset object
    ADORs.Open("Customers", ADOCn)
    'Create a new OLEDBDataAdapter object
    Dim ADOAdapter As New OleDbDataAdapter
    Dim ADODs As New DataSet
    'Use the Fill Method
    ADOAdapter.Fill(ADODs, ADORs, "emp")
    ADOAdapter.Dispose()
    ADOAdapter = Nothing
    ADOCn.Close()
    ADOCn = Nothing
    ADODs.Clear()
    ADODs.Dispose()
    ADODs = Nothing
    
  9. To save the project and the files that are associated with the project, click Save All on the File menu. The project is saved with the name that you originally used in step 4.
  10. To build the solution, click Build Solution on the Build menu.
  11. To test this code, press F5. Form1 is displayed.
  12. On Form1, click Button1.

REFERENCES

For additional information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
824684  (http://kbalertz.com/Feedback.aspx?kbNumber=824684/ ) Description of the Standard Terminology That Is Used to Describe Microsoft Product Updates, Tools, and Add-ons
310349  (http://kbalertz.com/Feedback.aspx?kbNumber=310349/ ) HOW TO: Use the OleDbDataAdapter to Fill a DataSet from an ADO Recordset in Visual Basic .NET
For additional information, visit the following Microsoft Developer Network (MSDN) Web sites:
Exposing COM Components to the .NET Framework
http://msdn2.microsoft.com/en-us/library/z6tx9dw3(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/z6tx9dw3(vs.71).aspx)
Advanced COM Interop
http://msdn2.microsoft.com/en-us/library/bd9cdfyx(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/bd9cdfyx(vs.71).aspx)
OleDbDataAdapter Class
http://msdn2.microsoft.com/en-us/library/system.data.oledb.oledbdataadapter(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/system.data.oledb.oledbdataadapter(vs.71).aspx)
OleDbDataAdapter Constructor
http://msdn2.microsoft.com/en-us/library/aa325900(VS.71).aspx (http://msdn2.microsoft.com/en-us/library/aa325900(VS.71).aspx)
OleDbDataAdapter.Fill Method (DataSet, Object, String)
http://msdn2.microsoft.com/en-us/library/aa325908(VS.71).aspx (http://msdn2.microsoft.com/en-us/library/Aa325908(VS.71).aspx)

APPLIES TO
  • Microsoft Visual Studio .NET 2003 Enterprise Architect
  • Microsoft Visual Studio .NET 2003 Enterprise Developer
  • Microsoft Visual Studio .NET 2003 Professional Edition
  • Microsoft ASP.NET 1.1
  • Microsoft .NET Framework 1.1
Keywords: 
kbhotfixserver kbqfe kbdataadapter kbdatabase kbfix kbbug KB831222
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Dhar - dharjha Report As Irrelevant  
Written: 3/26/2004 2:21 AM
I have a question whether it is possible to bind more than one dropdownlist with same dataadapter. I already tried in loops but it dose't work. Can somebody help? Dhar Jha