In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "how to realize the automatic increment column of ADO.NET". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1.ADO.NET expression column
ADO.NET also allows users to create and define expression columns. Expressions in ADO+ are used to filter, calculate, and summarize column information
To create an expression column, you need to set the DataType property to the type appropriate for the value returned by the expression, and then set the Expression property to a valid expression:
DataColumn dc = New DataColumn; dc.DataType = System.Type.GetType ("System.Currency"); dc.Expression = "total * .086"
You can also use the Add method to create an expression column. For example, the following code adds a column that calculates a discount based on 10% of the customer's purchase amount. This expression multiplies the column named "Purchases" by 10%.
When the table adds data, the value of this column will be 10% of the value in the total column
DataColumn dc= New DataColumn; dc= dt.Columns.Add ("rectg", System.Type.GetType ("System.Double"), "total * 0.1")
2.ADO.NET auto increment column
Another feature of DataColumn is its ability to act as an automatic increment column. Auto increment column automatically increases the value in a new column when it is added. To create an auto-increment column, you need to set the AutoIncrement property of the column to true. Once this property is set, the column starts with the numeric value defined in the column's AutoIncrementSeed property. After a column is added, the value of the auto-increment column is incremented as a step by the value in the column's AutoIncrementStep property.
Dc = dt.Columns.Add ("CustID", System.Type.GetType ("System.Int32")); dc.AutoIncrement = true; dc.AutoIncrementSeed = 1; dc.AutoIncrementStep = 1
Create a primary keyword for the table
Dt.PrimaryKey = new DataColumn [] {dt ["CustID"]}
3.ADO.NET adds data to the table
Now that you have a table with columns and keywords, you can add some data.
DataRow dtRow = null; for (int I = 0; 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: 0
*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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.