D
dotnet-MS
Hello!!
You would be welcome to answer the Question:
I make a DataSet's instance(sfSalesPlanDataSet) of DB's Table,
Add new DataRow into sfSalesPlanDataSet, and seek a record,
But When I Creating the DataRow, seek the record, it becomes very slow.
the following code is the sample:
When running the <***Sample 1***>, it is very fast (3 seconds);
When running the <***Sample 2***>, it becomes very very slow (20 minutes);
<***Sample 1***>
Dim i As Integer = 0
Dim j As Random = New Random(10000)
'sfSalesPlanDataSet: DataSet's Instance of a DB's Table
For i = 0 To 10000 ':loop 1
'Create a new data row
Dim dataRow As DataRow = sfSalesPlanDataSet.Tables(0).NewRow()
'Set value to datarow
dataRow(0) = "A"
dataRow(1) = i.ToString()
dataRow(2) = "200405"
dataRow(3) = 100.0
'add dataRow to the dataTable
sfSalesPlanDataSet.Tables(0).Rows.Add(dataRow)
Next
'seek the record from the DataTable
For i = 0 To 10000 ':loop 2
Dim selectedRecords() As DataRow = Nothing
selectedRecords =
sfSalesPlanDataSet.Tables(0).Select(String.Format("ITEMNO = '{0}'",
i.ToString()))
Next
<***Sample 2***>
Dim i As Integer = 0
Dim j As Random = New Random(10000)
'sfSalesPlanDataSet: DataSet's Instance of a DB's Table
For i = 0 To 10000 ':loop 1
'Create a new data row
Dim dataRow As DataRow = sfSalesPlanDataSet.Tables(0).NewRow()
'Set value to datarow
dataRow(0) = "A"
dataRow(1) = i.ToString()
dataRow(2) = "200405"
dataRow(3) = 100.0
'add dataRow to the dataTable
sfSalesPlanDataSet.Tables(0).Rows.Add(dataRow)
'seek the record from the DataTable
Dim selectedRecords() As DataRow = Nothing
selectedRecords =
sfSalesPlanDataSet.Tables(0).Select(String.Format("ITEMNO = '{0}'",
i.ToString()))
Next
From Yejian ([email protected])
You would be welcome to answer the Question:
I make a DataSet's instance(sfSalesPlanDataSet) of DB's Table,
Add new DataRow into sfSalesPlanDataSet, and seek a record,
But When I Creating the DataRow, seek the record, it becomes very slow.
the following code is the sample:
When running the <***Sample 1***>, it is very fast (3 seconds);
When running the <***Sample 2***>, it becomes very very slow (20 minutes);
<***Sample 1***>
Dim i As Integer = 0
Dim j As Random = New Random(10000)
'sfSalesPlanDataSet: DataSet's Instance of a DB's Table
For i = 0 To 10000 ':loop 1
'Create a new data row
Dim dataRow As DataRow = sfSalesPlanDataSet.Tables(0).NewRow()
'Set value to datarow
dataRow(0) = "A"
dataRow(1) = i.ToString()
dataRow(2) = "200405"
dataRow(3) = 100.0
'add dataRow to the dataTable
sfSalesPlanDataSet.Tables(0).Rows.Add(dataRow)
Next
'seek the record from the DataTable
For i = 0 To 10000 ':loop 2
Dim selectedRecords() As DataRow = Nothing
selectedRecords =
sfSalesPlanDataSet.Tables(0).Select(String.Format("ITEMNO = '{0}'",
i.ToString()))
Next
<***Sample 2***>
Dim i As Integer = 0
Dim j As Random = New Random(10000)
'sfSalesPlanDataSet: DataSet's Instance of a DB's Table
For i = 0 To 10000 ':loop 1
'Create a new data row
Dim dataRow As DataRow = sfSalesPlanDataSet.Tables(0).NewRow()
'Set value to datarow
dataRow(0) = "A"
dataRow(1) = i.ToString()
dataRow(2) = "200405"
dataRow(3) = 100.0
'add dataRow to the dataTable
sfSalesPlanDataSet.Tables(0).Rows.Add(dataRow)
'seek the record from the DataTable
Dim selectedRecords() As DataRow = Nothing
selectedRecords =
sfSalesPlanDataSet.Tables(0).Select(String.Format("ITEMNO = '{0}'",
i.ToString()))
Next
From Yejian ([email protected])