sls@cnicorp.com
Member
- Joined
- Dec 28, 2004
- Messages
- 7
- Programming Experience
- 5-10
My code crashes with an out of memory error can any one temm be how to fix this...
VB.NET:
Public Function StoreZip(ByRef Image_ID As Long, ByRef FileName As String, ByRef SourceType As String) As Boolean
Dim mStream As ADODB.Stream
Dim rs As New ADODB.Recordset
Dim Numberof As Short
Dim Query As String
Dim SourceDate As Date
Dim fso As New Scripting.FileSystemObject
Dim Enumber As Integer
Query = ""
StoreZip = False
Try
If StateOK() Then
SourceDate = FileDateTime(FileName)
Query = "Select * from images where Image_ID = " & Image_ID
mStream = New ADODB.Stream
rs = New ADODB.Recordset
rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient
rs.Open(Query, pdtconn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)
If CNIDEBUG1 Then
Call DebugOut("StoreGraphic", 1, "Query = " & Query & " - Filename " & FileName)
End If
Numberof = rs.RecordCount
mStream.Type = ADODB.StreamTypeEnum.adTypeBinary
mStream.Open()
mStream.LoadFromFile(FileName)
If Numberof = 0 Then
rs.AddNew()
End If
rs.Fields("Image_ID").Value = Image_ID
rs.Fields("SourceDate").Value = SourceDate
rs.Fields("Type").Value = SourceType
rs.Fields("Picture").Value = mStream.Read ' THIS Line Fails :mad:
rs.Update()
mStream.Close()
rs.Close()
StoreZip = True
File.Delete(FileName)
Else
If CNIDEBUG3 Then
Call DebugOut("StoreGraphic", 3, "Not Connected State Not OK")
End If
End If
Catch ex As Exception
Enumber = Err.Number
Call DebugOut("StoreGraphic", 3, "On error " & Err.Number & " " & ErrorToString())
If (Enumber = 3265) Or (Enumber = -2147217900) Or (Enumber = 3704) Then
Call DebugOut("StoreGraphic", 3, "On error Exit Condition Query = " & Query)
End If
End Try
End Function