Click here to Skip to main content
15,892,072 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I am stored binary data in one table,in For loop gets binary data one by one,below is my code in that
fadts is datatable contains 3 rows,when first time it works fine,second time when goes to fill data in dataadapter it throws error,

VB
           For Each row1 As DataRow In fadts.Rows
                    callclearsql()
                    System.Threading.Thread.Sleep(2000)
                    Dim facons1 As New SqlConnection(My.Settings.CS)
                    facons1.Open()
                    Dim fadrs1 As New SqlDataAdapter("SELECT ID,DocumentExtension,DocumentName,[Document]  FROM FileStore  where ID=" & row1("ID").ToString & "", facons1)
                    Dim fadts1 As New DataTable
                    fadrs1.SelectCommand.CommandTimeout = 0
                    fadts1.Rows.Clear()
                    fadrs1.Fill(fadts1)' Here got Exception of type 'System.OutOfMemoryException' was thrown.

                    Writelog("above loop1.1")
Next


It work only first loop,second time it throws error,[Document] column contains binary data.

Pls reply asap

Regards
Aravind

What I have tried:

I did dispose,clear and close for fadrs1,fadts1 and sql connection,but even it throws error.
Posted
Updated 31-Oct-16 22:50pm
v3
Comments
Dave Kreskowiak 31-Oct-16 22:54pm    
How big are these rows in bytes, each?
Aravindba 1-Nov-16 0:16am    
300 mb ,means we using filestream table. [Document] varbinary(MAX) Checked,for first file can get,second time it throws error.if all files below 50 mb then no problem with same coding.Pls tell me how solve this problem . i added below query in before and after select command and in every 5 lines

DBCC FREESYSTEMCACHE ('ALL') WITH MARK_IN_USE_FOR_REMOVAL; DBCC FREESESSIONCACHE WITH NO_INFOMSGS; DBCC FREEPROCCACHE WITH NO_INFOMSGS; DBCC DROPCLEANBUFFERS; DBCC FREEPROCCACHE ('internal'); DBCC FREESESSIONCACHE WITH NO_INFOMSGS; DBCC FREESYSTEMCACHE ('ALL', internal);
Aravindba 1-Nov-16 4:49am    
Thanks for ur effort,finally i found solution from this link
https://msdn.microsoft.com/en-us/library/87z0hy49(v=vs.110).aspx

Thanks

1 solution

Thanks,finally i found solution form this link,Thanks MicroSoft
https://msdn.microsoft.com/en-us/library/87z0hy49(v=vs.110).aspx
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900