Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of ADO.Net typed DataSet

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the use of ADO.Net typed DataSet, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to know about it.

First, the disadvantages of weak type DataSet:

1, can only be referenced by the column name, dataset.Tables [0] .Rows [0] ["Age"]. If you write the column name incorrectly, you will not find the error when compiling, so you must keep the column name in mind when developing.

2. Int age=Convert.ToInt32 (dataset.Rows [0] ["Age"]), the value of the field fetched is of type object, so type conversion must be carried out carefully, which is not only troublesome, but also error-prone.

3. Passing the DataSet to other users makes it difficult for the user to identify which columns are available.

4, the runtime can only know all the column names, data binding is troublesome, and can not use the rapid development features of Winform and ASP.Net.

5. Write strongly typed DataSet (typed DataSet,TypedDataSet) yourself, create PersonDataSet classes that inherit from DataSet, and encapsulate int? Properties such as Age and methods such as bool IsAgeNull to populate the PersonDataSet.

2. VS automatically generates strongly typed DataSet:

1. Step: add-> New item-> dataset

2. Drag and drop the table from Server Explorer into DataSet. Note that the drag-and-drop process automatically generates strongly typed DataSet and other classes according to the table structure, without dragging the data over, the program is still connected to the database, and the database connection string is automatically written in App.Config.

3. Use DataSet in the code as an example: CC_RecordTableAdapter adapter=new CC_RecordTableAdapter (); how do I know the class name of Adapter? Select the Adapter,Name attribute in the lower half of the DataSet to be the class name. You need to right-click the class name-> parse

4. Get all the data: adapter.GetData (), example program: traversing and displaying all the data, I

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 276

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report