ADO.NET Series Quiz

xiaoxiao2021-03-06  52

There is a code, you can test it in the local Form

DIM DT AS DATATABLE DIM DV AS DATAVIEW

Private sub button2_click (Byval E AS System.EventArgs) Handles Button2.Click DIM DRV AS DATAROWVIEW = DV (0)

Drv.delete () msgbox (dt.rows.count) End Sub

Private Sub Form1_Load (Byval E AS System.EventArgs) Handles MyBase.Load Dt = New DataTable

Dt.columns.add ("col1", gettype (string)) DT.COLUMNS.ADD ("col2", gettype (string))

DIM DR AS DATAROW for I as integer = 0 to 9 dr = dt.newrow dr (0) = i.to.Tostring () DR (1) = i.toTString () Dt.Rows.Add (DR) Next Dt.acceptchanges DV = New DataView (DT)

End Sub

You will find that when you click on the button, you will display 10 until you have left the wrong report.

Question 1. Why is MsgBox (Dt.Rows.count) always returns 10

Question 2. Simply modify a line of code, you can display the number of real records, do you know why?

The problem is actually very simple. You find the answer to the ADO.NET's data cache mechanism after answering.

转载请注明原文地址:https://www.9cbs.com/read-116384.html

New Post(0)