Link to home
Start Free TrialLog in
Avatar of RIAS
RIASFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Memory out exception when using sqldatareader for extracting bytes

Hello,
I have an varbinary column which stores bytes for an image.
The query is throwing an exception Out of memory .
I am using a Stored Procedure to get the query result.
This is the code:
  Public Sub Populate(ByVal Command As SqlCommand)
            'Accept command as string and fill the datatable with the result of sql query
            
            Dim dt = New DataTable
            Dim SQLdr As SqlDataReader
        Try

            SQLdr = Command.ExecuteReader(CommandBehavior.SequentialAccess)
            dt.BeginLoadData()
            dt.Load(SQLdr)
            dt.EndLoadData()

            Command.Connection.Close()
            Application.DoEvents()
            Command.Dispose()
            Data_Table = dt

        Catch MyException As SqlException
            MessageBox.Show("Stored procedure Error: MySQL code: " &
            MyException.Number & "  " &
            MyException.Message)
            End Try
        End Sub

Open in new window


Any suggestions are appreciated as I have been struggling with this for quite a while.

Thanks
Avatar of louisfr
louisfr

Are you retrieving the whole table? How much data does the table contain?
ASKER CERTIFIED SOLUTION
Avatar of Máté Farkas
Máté Farkas
Flag of Hungary image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RIAS

ASKER

Thanks.There is column of pictures saved as bytes , it has around 300 photos.
Thanks
There is no good solution for that problem.