Microsoft Knowledge Base Email Alertz

KBAlertz.com: (310128) - The DataAdapter object is optimized for read-only scenarios by default. The Fill method only retrieves the amount of schema that is necessary to populate a DataSet object. To obtain the additional schema that are necessary to update or validate...

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]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **


Bug Tracking Software
For bug tracking software or defect tracking software or issue tracking software, visit Axosoft.


Community Site



We Send hundreds of thousands of emails using ASP.NET Email



Expert Web Design & Graphic Design
Design44.com

ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

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




Article ID: 310128 - Last Review: February 22, 2007 - Revision: 2.1

INFO: When to Use FillSchema and MissingSchemaAction with the DataAdapter in ADO.NET

This article was previously published under Q310128

SUMMARY

The DataAdapter object is optimized for read-only scenarios by default. The Fill method only retrieves the amount of schema that is necessary to populate a DataSet object. To obtain the additional schema that are necessary to update or validate DataSet objects, use one of the following methods for DataSet objects that are populated by the DataAdapater:
  • Use the FillSchema method of the DataAdapter.
  • Use the AddWithKey enumeration for the MissingSchemaAction property of the DataAdapter.
This article describes how to choose between these two methods when you want to populate updateable DataSet objects with the DataAdapter.

MORE INFORMATION

Setting the MissingSchemaAction property of the DataAdapter to AddWithKey is analogous to using the DataAdapter.FillSchema method. Both methods add schema information about primary keys, AutoIncrement fields, nullable fields, and unique indexes.

When to Use DataAdapter's FillSchema Method

Use the FillSchema method of the DataAdapter if you will be reading the same data multiple times. If you use MissingSchemaAction.AddWithKey, the schema is fetched with every call to the DataAdapter.Fill method.

When to Use DataAdapter's MissingSchemaAction.AddWithKey Method

  • Use DataAdapter.MissingSchemaAction.AddWithKey when you are retrieving multiple result sets in a single batch. If you are using the OLE DB .NET Data Provider, the DataAdapter.FillSchema method retrieves schema information for only the first result set when there are multiple SQL SELECT commands in a batch.
  • Use DataAdapter.MissingSchemaAction.AddWithKey if you are calling DataAdapter.Fill just one time for a DataSet.

When Not to Use Either FillSchema or MissingSchemaAction.AddWithKey

  • Do not use either method when you are obtaining a read-only DataSet to avoid adding unnecessary overhead.
  • Do not use either method when you use the Visual Design Tools to generate a DataSet because the code for updateability is already incorporated into the tool-generated DataSet class.
  • Do not use either method when you load a DataSet from XML if you want the DataSet to use the XML schema instead of a generated schema.

REFERENCES

For more information, see the following topics in the Microsoft Visual Studio .NET Help documentation:
DataAdapter.Fill Method
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataCommonDataAdapterClassFillTopic.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataCommonDataAdapterClassFillTopic.asp)

DataAdapter.FillSchema Method
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataCommonDataAdapterClassFillSchemaTopic.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataCommonDataAdapterClassFillSchemaTopic.asp)

DataAdapter.MissingSchemaAction Property
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataCommonDataAdapterClassMissingSchemaActionTopic.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataCommonDataAdapterClassMissingSchemaActionTopic.asp)

MissingSchemaAction Enumeration
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataMissingSchemaActionClassTopic.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataMissingSchemaActionClassTopic.asp)

Loading DataSet Schema Information from XML
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconloadingdatasetschemainformationfromxml.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconloadingdatasetschemainformationfromxml.asp)
For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base:
301248  (http://kbalertz.com/Feedback.aspx?kbNumber=301248/EN-US/ ) HOW TO: Update a Database from a DataSet Object by Using Visual Basic .NET
301216  (http://kbalertz.com/Feedback.aspx?kbNumber=301216/EN-US/ ) HOW TO: Populate a DataSet Object from a Database by Using Visual Basic .NET

APPLIES TO
  • Microsoft ADO.NET (included with the .NET Framework)
  • Microsoft ADO.NET 1.1
Keywords: 
kbdatabase kbinfo KB310128
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
       

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

Be the first to leave feedback, to help others about this knowledge base article.

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please