Click here to Skip to main content
15,881,866 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: self talking hangman vb console game tutorial Pin
Dave Kreskowiak31-Jul-19 16:23
mveDave Kreskowiak31-Jul-19 16:23 
AnswerRe: self talking hangman vb console game tutorial Pin
ZurdoDev6-Aug-19 10:06
professionalZurdoDev6-Aug-19 10:06 
QuestionMatlab DLL Function is returning nothing !! Pin
Member 1454417528-Jul-19 22:43
Member 1454417528-Jul-19 22:43 
QuestionRe: Matlab DLL Function is returning nothing !! Pin
Richard MacCutchan29-Jul-19 4:12
mveRichard MacCutchan29-Jul-19 4:12 
QuestionVB.NET x Google Maps - best routes Pin
Member 1454069824-Jul-19 18:02
Member 1454069824-Jul-19 18:02 
AnswerRe: VB.NET x Google Maps - best routes Pin
Mycroft Holmes24-Jul-19 21:06
professionalMycroft Holmes24-Jul-19 21:06 
AnswerRe: VB.NET x Google Maps - best routes Pin
Richard MacCutchan24-Jul-19 21:12
mveRichard MacCutchan24-Jul-19 21:12 
QuestionOutOfMemoryException in VB.Net Pin
DTGeek19-Jul-19 6:48
DTGeek19-Jul-19 6:48 
I posted this C# board first which was a mistake again I apologize. I work for this company where the old programmer was in the process of rewrite the source code with no documentation at all from VB.Net to C# Now we have 4 programs total and they all update from the same database and get price updates on items. My problem is on one of the programs if a customer was to do full sync which is the whole database list of well 60,000 items I get OutOfMemoryException when it imports the last category Items. Here are the Exceptions
Quote:
Exception thrown: 'System.OutOfMemoryException' in System.Data.dll
Exception thrown: 'System.OutOfMemoryException' in Microsoft.EntityFrameworkCore.Relational.dll
Exception thrown: 'System.OutOfMemoryException' in Microsoft.EntityFrameworkCore.Relational.dll
Exception thrown: 'System.OutOfMemoryException' in Microsoft.EntityFrameworkCore.dll
Exception thrown: 'System.OutOfMemoryException' in Microsoft.EntityFrameworkCore.dll


Private Function DoImpItems() As Boolean
        Dim percent As Integer = 0
        Dim currentRow As Integer = 0
        Dim ItemDataRow As DataSetPricing.ItemsRow
        Dim CommodityDataRow As DataSetPricing.CommoditiesRow
        Dim LevelTypeDataRow As DataSetPricing.LevelTypesRow
        Dim StatusDataRow As DataSetPricing.StatusRow
        Dim ManufacturerDataRow As DataSetPricing.ManufacturersRow
        Dim UomDataRow As DataSetPricing.UOMRow
        Dim WorkgroupDataRow As DataSetPricing.WorkGroupsRow
        Dim Item As Models.Item

        Manufacturers = ServiceLocator.Current.GetInstance(Of IManufacturers).Get
        WorkGroups = ServiceLocator.Current.GetInstance(Of IWorkgroups).Get
        LevelTypes = ServiceLocator.Current.GetInstance(Of ILevelTypes).Get
        ItemStatus = ServiceLocator.Current.GetInstance(Of IItemStatusTypes).Get
        UOM = ServiceLocator.Current.GetInstance(Of IUom).Get
       
        'Update Existing Items
        Try
            currentRow = 0

            For Each row In DataSetPricing.Items
                Item = ServiceLocator.Current.GetInstance(Of IItems).GetByRowId(row.RowID)

                If Not Item Is Nothing Then
                    If Not Item.DoNotUpdate Then
                        Item.EriNumber = row.ERINumber
                        Item.EriNumberSearch = row.ERINumber
                        Item.Comparative = row.Comparative
                        If row.ParentID <> 0 Then
                            ItemDataRow = DataSetPricing.Items.Where(Function(d) d.PK_ItemID = row.ParentID).SingleOrDefault
                            If Not ItemDataRow Is Nothing Then
                                Dim ItemParent As Models.Item = ServiceLocator.Current.GetInstance(Of IItems).GetByRowId(ItemDataRow.RowID)
                                If Not ItemParent Is Nothing Then
                                    Item.ParentId = ItemParent.PkItems
                                Else
                                    Item.ParentId = 0
                                End If
                            Else
                                Item.ParentId = 0
                            End If
                        Else
                            Item.ParentId = 0
                        End If

                        Item.CatalogNumber = row.CatalogNumber
                        Item.Description = row.Description
                        Item.MyCost = CDec(Math.Round(row.Cost * IIf(IsDBNull(Item.MyMultiplier), 1, Item.MyMultiplier), 2))
                        Item.Cost = row.Cost
                        Item.Retail = row.Retail
                        If Not Config.NoUpdateLabor Then
                            Item.Labor = row.Labor
                        End If
                        Item.EffectiveDate = row.DateEffective
                        Item.Comparative = row.Comparative
                        Item.UPC = Strings.Right(row.UPC, 5)
                        Item.AlphaIndex = row.AlphaIndex
                        Item.ReportGroup = row.ReportGroup
                        Item.ImKing = row.ImKing
                        Item.ImageUrl = IIf(IsDBNull(row.ImageURL), String.Empty, row.ImageURL)
                        Item.CatalogPageUrl = IIf(IsDBNull(row.CatalogPageURL), String.Empty, row.CatalogPageURL)
                        Item.LastCostUpdate = Date.Now

                        LevelTypeDataRow = DataSetPricing.LevelTypes.Where(Function(d) d.PK_LevelTypeID = row.FK_LevelTypeID).SingleOrDefault
                        If Not LevelTypeDataRow Is Nothing Then
                            Dim q = (From c In LevelTypes Where c.RowId = LevelTypeDataRow.RowID).SingleOrDefault
                            Item.FkLevel = q.LevelTypeId
                        Else
                            Item.FkLevel = 1
                        End If

                        StatusDataRow = DataSetPricing.Status.Where(Function(d) d.PK_StatusID = row.FK_StatusID).SingleOrDefault
                        If Not StatusDataRow Is Nothing Then
                            Dim q = (From c In ItemStatus Where c.Status = StatusDataRow.Description).SingleOrDefault
                            Item.FkStatus = q.PkItemStatusTypes
                        Else
                            Item.FkStatus = 1
                        End If

                        UomDataRow = DataSetPricing.UOM.Where(Function(d) d.PK_UOMID = row.FK_UOMID).SingleOrDefault
                        If Not UomDataRow Is Nothing Then
                            Dim q = (From c In UOM Where c.UOM = UomDataRow.ShortDescription).SingleOrDefault
                            Item.FkUom = q.IdUom
                        Else
                            Item.FkUom = 0
                        End If

                        WorkgroupDataRow = DataSetPricing.WorkGroups.Where(Function(d) d.PK_WorkGroupID = row.FK_WorkgroupID).SingleOrDefault
                        If Not WorkgroupDataRow Is Nothing Then
                            Dim q = (From c In WorkGroups Where c.RowId = WorkgroupDataRow.RowID).SingleOrDefault
                            Item.FkWorkgroup = q.PkWorkgroups
                        Else
                            Item.FkWorkgroup = 0
                        End If

                        CommodityDataRow = DataSetPricing.Commodities.Where(Function(d) d.PK_CommodityID = row.FK_CommodityID).SingleOrDefault
                        If Not CommodityDataRow Is Nothing Then
                            Dim q = ServiceLocator.Current.GetInstance(Of ICommodities).GetByRowId(CommodityDataRow.RowID)
                            Item.FkCommodityId = q.PkCommodityId
                        Else
                            Item.FkCommodityId = 0
                        End If

                        ManufacturerDataRow = DataSetPricing.Manufacturers.Where(Function(d) d.PK_ManufacturerID = row.FK_ManufacturerID).SingleOrDefault
                        If Not ManufacturerDataRow Is Nothing Then
                            Dim q = (From c In Manufacturers Where c.RowId = ManufacturerDataRow.RowID).FirstOrDefault
                            Item.FkManufacturer = q.PkManufacturerId
                        Else
                            Item.FkManufacturer = 0
                        End If
                    End If

                    ServiceLocator.Current.GetInstance(Of IItems).Update(Item)
                Else
                    Dim entity As New Models.Item

                    entity.EriNumber = row.ERINumber
                    entity.EriNumberSearch = row.ERINumber
                    entity.CatalogNumber = row.CatalogNumber
                    entity.Description = row.Description
                    entity.MyCost = row.Cost
                    entity.Cost = row.Cost
                    entity.Retail = row.Retail
                    entity.Labor = row.Labor
                    entity.EffectiveDate = row.DateEffective
                    entity.Comparative = row.Comparative
                    entity.UPC = Strings.Right(CStr(row.UPC), 5)
                    entity.AlphaIndex = row.AlphaIndex
                    entity.ReportGroup = row.ReportGroup
                    entity.ImKing = row.ImKing
                    entity.MyMultiplier = 1
                    entity.RowId = row.RowID
                    entity.ImageUrl = row.ImageURL
                    entity.CatalogPageUrl = row.CatalogPageURL
                    entity.LastCostUpdate = Date.Now
                    entity.DefaultCostCode = 0

                    If row.ParentID <> 0 Then
                        ItemDataRow = DataSetPricing.Items.Where(Function(d) d.PK_ItemID = row.ParentID).SingleOrDefault
                        If Not ItemDataRow Is Nothing Then
                            Dim ItemParent As Models.Item = ServiceLocator.Current.GetInstance(Of IItems).GetByRowId(ItemDataRow.RowID)
                            If Not ItemParent Is Nothing Then
                                entity.ParentId = ItemParent.PkItems
                            Else
                                entity.ParentId = 0
                            End If
                        Else
                            entity.ParentId = 0
                        End If
                    Else
                        entity.ParentId = 0
                    End If

                    LevelTypeDataRow = DataSetPricing.LevelTypes.Where(Function(d) d.PK_LevelTypeID = row.FK_LevelTypeID).SingleOrDefault
                    If Not LevelTypeDataRow Is Nothing Then
                        Dim q = (From c In LevelTypes Where c.RowId = LevelTypeDataRow.RowID).SingleOrDefault
                        entity.FkLevel = q.LevelTypeId
                    Else
                        entity.FkLevel = 1
                    End If

                    StatusDataRow = DataSetPricing.Status.Where(Function(d) d.PK_StatusID = row.FK_StatusID).SingleOrDefault
                    If Not StatusDataRow Is Nothing Then
                        Dim q = (From c In ItemStatus Where c.Status = StatusDataRow.Description).SingleOrDefault
                        entity.FkStatus = q.PkItemStatusTypes
                    Else
                        entity.FkStatus = 1
                    End If

                    UomDataRow = DataSetPricing.UOM.Where(Function(d) d.PK_UOMID = row.FK_UOMID).SingleOrDefault
                    If Not UomDataRow Is Nothing Then
                        Dim q = (From c In UOM Where c.UOM = UomDataRow.ShortDescription).SingleOrDefault
                        entity.FkUom = q.IdUom
                    Else
                        entity.FkUom = 0
                    End If

                    WorkgroupDataRow = DataSetPricing.WorkGroups.Where(Function(d) d.PK_WorkGroupID = row.FK_WorkgroupID).SingleOrDefault
                    If Not WorkgroupDataRow Is Nothing Then
                        Dim q = (From c In WorkGroups Where c.RowId = WorkgroupDataRow.RowID).SingleOrDefault
                        entity.FkWorkgroup = q.PkWorkgroups
                    Else
                        entity.FkWorkgroup = 0
                    End If

                    CommodityDataRow = DataSetPricing.Commodities.Where(Function(d) d.PK_CommodityID = row.FK_CommodityID).SingleOrDefault
                    If Not CommodityDataRow Is Nothing Then
                        Dim q = ServiceLocator.Current.GetInstance(Of ICommodities).GetByRowId(CommodityDataRow.RowID)
                        entity.FkCommodityId = q.PkCommodityId
                    Else
                        entity.FkCommodityId = 0
                    End If

                    ManufacturerDataRow = DataSetPricing.Manufacturers.Where(Function(d) d.PK_ManufacturerID = row.FK_ManufacturerID).SingleOrDefault
                    If Not ManufacturerDataRow Is Nothing Then
                        Dim q = (From c In Manufacturers Where c.RowId = ManufacturerDataRow.RowID).FirstOrDefault
                        entity.FkManufacturer = q.PkManufacturerId
                    Else
                        entity.FkManufacturer = 0
                    End If

                    ServiceLocator.Current.GetInstance(Of IItems).Add(entity)
                End If

                currentRow += 1
                percent = CInt((currentRow / DataSetPricing.Items.Rows.Count) * 100)
                BackgroundWorker.ReportProgress(percent)
            Next
        Catch ex As Exception
            secondLevelMsg = ex.Message

            Return False

            Exit Function
        End Try

        Return True
    End Function

AnswerRe: OutOfMemoryException in VB.Net Pin
Gerry Schmitz19-Jul-19 12:06
mveGerry Schmitz19-Jul-19 12:06 
GeneralRe: OutOfMemoryException in VB.Net Pin
DTGeek23-Jul-19 5:14
DTGeek23-Jul-19 5:14 
GeneralRe: OutOfMemoryException in VB.Net Pin
DTGeek30-Jul-19 4:59
DTGeek30-Jul-19 4:59 
Questioncontextmenu when 2 files are selected Pin
JR21218-Jul-19 1:58
JR21218-Jul-19 1:58 
AnswerRe: contextmenu when 2 files are selected Pin
Eddy Vluggen23-Jul-19 0:35
professionalEddy Vluggen23-Jul-19 0:35 
GeneralRe: contextmenu when 2 files are selected Pin
JR21223-Jul-19 4:30
JR21223-Jul-19 4:30 
QuestionProblem with treeview drag and drop Pin
mo149212-Jul-19 9:02
mo149212-Jul-19 9:02 
QuestionHow to commnuicated between VBS and C# Pin
Member 145249558-Jul-19 21:48
Member 145249558-Jul-19 21:48 
GeneralRe: How to commnuicated between VBS and C# Pin
Ralf Meier8-Jul-19 23:56
mveRalf Meier8-Jul-19 23:56 
AnswerRe: How to commnuicated between VBS and C# Pin
Dave Kreskowiak9-Jul-19 6:19
mveDave Kreskowiak9-Jul-19 6:19 
GeneralRe: How to commnuicated between VBS and C# Pin
Member 145249559-Jul-19 15:20
Member 145249559-Jul-19 15:20 
GeneralRe: How to commnuicated between VBS and C# Pin
Dave Kreskowiak10-Jul-19 5:04
mveDave Kreskowiak10-Jul-19 5:04 
Questionhow to deal with this error Pin
Member 145002187-Jul-19 22:09
Member 145002187-Jul-19 22:09 
NewsRe: how to deal with this error Pin
CHill608-Jul-19 1:45
mveCHill608-Jul-19 1:45 
AnswerRe: how to deal with this error Pin
Dave Kreskowiak8-Jul-19 2:11
mveDave Kreskowiak8-Jul-19 2:11 
Questionemail a attached file vb.net Pin
Member 145002187-Jul-19 21:00
Member 145002187-Jul-19 21:00 
AnswerRe: email a attached file vb.net Pin
Chris Quinn8-Jul-19 0:58
Chris Quinn8-Jul-19 0:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.