16,018,938 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Visual Basic questions
View Javascript questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by 1DSparrows (Top 22 by date)
1DSparrows
13-Mar-18 21:08pm
View
Here how I used your code:
If (dt.Rows.Count > 100000) Then
Dim scr As DataTable = New DataTable()
scr.Columns.Add(New DataColumn("key_id", Type.GetType("System.Int32")))
For _c As Integer = 0 To dt.Rows.Count
scr.Rows.Add(New Object() {_c})
Next
Dim increasement As Integer = 30000
Dim curVal As Integer = 1
Dim result As DataRow()
Dim ds As DataSet = New DataSet()
Do
result = scr.Select(String.Format("key_id >={0} And key_id<{1}", curVal, curVal + increasement)).Clone()
If result.Length > 0 Then
Dim tmp As DataTable = scr.Clone()
Dim sb As StringBuilder = New StringBuilder()
For Each dr As DataRow In result
tmp.Rows.Add(New Object() {dr("key_id")})
sb.Append(String.Format("{0};", dr("key_id")))
Next
ds.Tables.Add(tmp)
Console.WriteLine("{0}", sb.ToString())
sb = Nothing
End If
curVal += increasement
Loop While (result.Length > 0)
End If
dt.WriteXml(writer, False)
1DSparrows
13-Mar-18 19:29pm
View
The code was correct but the problem is the looping just continue and nothing happened. I don't even got successfully uploaded the data into my database. Thus, console.readkey() is for console app? I'm doing web application in ASP.NET application (like one running in IIS).
I tried to upload 50 records to check then I put 10 on the increasement but then 39 records only was uploaded.
1DSparrows
13-Mar-18 4:43am
View
Hi I still get the out of memory error when I upload 130,000 records.
1DSparrows
13-Mar-18 4:18am
View
Deleted
okay, I'm trying your code now. I already uploaded the data and it is 130,000. I'm waiting for the result. It will just take time because of the looping right?
1DSparrows
13-Mar-18 3:58am
View
is increasement As Integer = 30 always, or I can change it base on the range I need that the table can have? so if I put 30000, the table will have each 30000?
1DSparrows
13-Mar-18 3:07am
View
Sorry I didn't mention it. I'm working on VS2005.
1DSparrows
13-Mar-18 1:20am
View
okay sorry for that, I already edit my question awhile ago. I even posted the updated code but seems no one see.
1DSparrows
12-Mar-18 23:30pm
View
Because it not answered yet, still not getting the correct code. The solution given encounter error.
1DSparrows
12-Mar-18 23:20pm
View
Deleted
I updated my code with the correct logic in dt.select.
If (dt.Rows.Count > 100000) Then
Dim Columns As DataRow = dt.NewRow
Dim c = dt.Rows.Count / 30000
Dim SNumber = Convert.ToInt64(System.Math.Ceiling(c))
dt.Columns.Add("Key_Id", GetType(String))
If c = CDbl(c) Then
c = System.Math.Floor(c + 1)
Dim dtArr(c) As DataTable
For j As Integer = 0 To c
dtArr(j) = dt.Select("Key_Id <= 1 And Key_Id >= 30000").Clone()
dtArr(j) = dt.Select("Key_Id <= 30001 And Key_Id >= 60000").Clone()
dtArr(j) = dt.Select("Key_Id <= 60001 And Key_Id >= 90000").Clone()
dtArr(j) = dt.Select("Key_Id <= 90001 And Key_Id >= 120000").Clone()
dtArr(j) = dt.Select("Key_Id <= 120001 And Key_Id >= 150000").Clone()
Next
End If
End If
1DSparrows
12-Mar-18 23:08pm
View
I already got it corrected, thanks
1DSparrows
12-Mar-18 20:52pm
View
I used your code above but AsEnumerable' is not a member of 'System.Data.DataTable. I add a reference but still got the error. Both Method is not working. I'm using Visual Studio 2005.
1DSparrows
12-Mar-18 5:55am
View
Oh.okay
1DSparrows
12-Mar-18 5:45am
View
What?
1DSparrows
12-Mar-18 3:41am
View
I used your code but still getting the error, Unable to cast object of type 'System.Data.DataRow[]' to type 'System.Data.DataTable'and CopyToDataTable is not a member of system array.
1DSparrows
12-Mar-18 3:37am
View
CopyToDataTable is not a member of system array
1DSparrows
12-Mar-18 3:26am
View
I come up with this code base on your suggestion but encounter error. Unable to cast object of type 'System.Data.DataTable' to type 'myStronglyTypedDataTable'
1DSparrows
12-Mar-18 3:26am
View
Dim _New_dt As New DataTable()
_New_dt = dt
dt.Columns.Add("Key_Id", GetType(String))
Dim c = _New_dt.Rows.Count / 30000
Dim SheetNumber = Convert.ToInt64(Math.Ceiling(c))
If c = CDbl(c) Then
c = Math.Floor(c + 1)
Dim dtArr(c) As DataTable
dtArr(c) = dt.Select("key_id <= 1 And key_id >= 30000").Clone()
dtArr(c) = dt.Select("key_id <= 61000 And key_id >= 90000").Clone()
dtArr(c) = dt.Select("key_id <= 91000 And key_id >= 120000").Clone()
dtArr(c) = dt.Select("key_id <= 121000 And key_id >= 150000").Clone()
1DSparrows
12-Mar-18 3:00am
View
Dim tables As List(Of DataTable) = New List(Of DataTable)()
Dim batchSize As Integer
Dim c As Integer = 0
Dim j As Integer = 1
Dim rowCount As Integer = 0
Dim tempDt As DataTable = dt.Clone()
tempDt.TableName = "scm_move_order" & j.ToString()
tempDt.Clear()
For Each row As DataRow In dt.Rows
rowCount += 1
Dim newRow As DataRow = tempDt.NewRow()
newRow.ItemArray = row.ItemArray
tempDt.Rows.Add(newRow)
c += 1
If c = batchSize Or rowCount = dt.Rows.Count Then
tables.Add(tempDt)
j += 1
tempDt = dt.Clone()
tempDt.TableName = "scm_move_order" & j.ToString()
tempDt.Clear()
c = 0
End If
Next
1DSparrows
12-Mar-18 3:00am
View
I followed this code but still got the error of out of memory
1DSparrows
12-Mar-18 2:38am
View
so dtArr is the only wrong in my coding?
1DSparrows
12-Mar-18 2:01am
View
dtArr has the possibility to be decimal,
1DSparrows
12-Mar-18 1:25am
View
@javed I already go through that link but haven't fixed my code on the right one.
Show More