Click here to Skip to main content
15,917,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hello Guys,

I need you help

I developed an asp.net application using ajax-enabled form ajax control toolkit like hovermenuextender.

Everything was fine until I tried to make many SELECT Query with oledb with only one oledb.connection Command and reader.

Once I get all the results from my query then my website is not ajax-enabled anymore.

The Timer delayed like 30, I put the timer on master page. The timer worked fine when I opened another page that doesn't use large query process.
I always close datareader right after reader has been executed. I wonder why this may occur when all the data has been displayed
when I check to sqlserver.exe on task manager and see that it uses around 50% of CPU usage, and doesn't decrease.

I hope somebody could give me some advice, I will appreciate it so much
Thanks.
Kindly Regard.


Danang Prakoso


HERE's The Code
Imports System.Data
Partial Class UnpackingProgress
    Inherits System.Web.UI.Page
    Public dbCon As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("ILog").ConnectionString)
    Public dbCommand As New OleDb.OleDbCommand
    Public dbReader As OleDb.OleDbDataReader
    Public lstPL As List(Of ProductionPlan)
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        dbCommand.Connection = dbCon
        dbCon.Open()
        UpdateData()
        dbCon.Close()
        dbCon.Dispose()
        dbCommand.Dispose()
        UpdateDisplay()
        FinalizeData()
    End Sub
    Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
        
    End Sub
    Private Sub FinalizeData()
        Dim a, b, c As Integer
        For a = 0 To lstPL.Count - 1
            For b = 0 To lstPL(a).Stations.Count - 1
                For c = 0 To lstPL(a).Stations(b).Trolleys.Count - 1
                    lstPL(a).Stations(b).Trolleys(c).FinalizeMe()
                Next
                lstPL(a).Stations(b).FinalizeMe()
                lstPL(a).Stations(b).Trolleys.Clear()
            Next
            lstPL(a).FinalizeMe()
            lstPL(a).Stations.Clear()
        Next
        lstPL.Clear()
    End Sub
    Private Sub UpdateData()
        lstPL = New List(Of ProductionPlan)
        Dim pl As ProductionPlan
        dbCommand.CommandText = "SELECT DISTINCT TOP (4) ID, Consignment, Lot, Varian, [Type] FROM Prod_plan  WHERE status = 1 ORDER BY ID"
        dbReader = dbCommand.ExecuteReader
        If dbReader.HasRows Then
            While dbReader.Read
                pl = New ProductionPlan
                pl.dbCommand = dbCommand
                pl.dbReader = dbReader
                pl.pid = dbReader.GetInt32(0)
                pl.cons = dbReader.GetString(1)
                pl.lot = dbReader.GetString(2)
                pl.varian = dbReader.GetString(3)
                pl.type = dbReader.GetString(4).Substring(0, 1)
                lstPL.Add(pl)
            End While
        End If
        dbReader.Close()

        Dim i As Integer
        For i = 0 To lstPL.Count - 1
            lstPL(i).GetStations()
        Next

        If lstPL.Count = 0 Then
            pl = New ProductionPlan
            lstPL.Add(pl)
            lstPL.Add(pl)
            lstPL.Add(pl)
            lstPL.Add(pl)
        ElseIf lstPL.Count = 1 Then
            pl = New ProductionPlan
            lstPL.Add(pl)
            lstPL.Add(pl)
            lstPL.Add(pl)
        ElseIf lstPL.Count = 2 Then
            pl = New ProductionPlan
            lstPL.Add(pl)
            lstPL.Add(pl)
        ElseIf lstPL.Count = 3 Then
            pl = New ProductionPlan
            lstPL.Add(pl)
        End If
    End Sub
    Private Function CalculateData(ByVal row As Integer, ByVal pl As ProductionPlan) As String
        If pl.pid = 0 Then
            Return "-"
        Else
            Select Case row
                Case 1
                    Return Math.Round((pl.Stations(3).completeTrolley + pl.Stations(1).completeTrolley + pl.Stations(35).completeTrolley) / (pl.Stations(3).totalTrolley + pl.Stations(1).totalTrolley + pl.Stations(35).totalTrolley) * 100) & "%"
                Case 2
                    Return Math.Round((pl.Stations(16).completeTrolley) / (pl.Stations(16).totalTrolley) * 100) & "%"
                Case 3
                    Return Math.Round((pl.Stations(17).completeTrolley) / (pl.Stations(17).totalTrolley) * 100) & "%"
                Case 4
                    Return Math.Round((pl.Stations(18).completeTrolley + pl.Stations(19).completeTrolley + pl.Stations(5).completeTrolley) / (pl.Stations(18).totalTrolley + pl.Stations(19).totalTrolley + pl.Stations(5).totalTrolley) * 100) & "%"
                Case 5
                    Return Math.Round((pl.Stations(20).completeTrolley + pl.Stations(21).completeTrolley) / (pl.Stations(20).totalTrolley + pl.Stations(21).totalTrolley) * 100) & "%"
                Case 6
                    Return Math.Round((pl.Stations(22).completeTrolley + pl.Stations(23).completeTrolley) / (pl.Stations(22).totalTrolley + pl.Stations(23).totalTrolley) * 100) & "%"
                Case 7
                    Return Math.Round((pl.Stations(24).completeTrolley) / (pl.Stations(24).totalTrolley) * 100) & "%"
                Case 8
                    Return Math.Round((pl.Stations(25).completeTrolley + pl.Stations(4).completeTrolley) / (pl.Stations(25).totalTrolley + pl.Stations(4).totalTrolley) * 100) & "%"
                Case 9
                    Return Math.Round((pl.Stations(26).completeTrolley + pl.Stations(27).completeTrolley + pl.Stations(6).completeTrolley + pl.Stations(7).completeTrolley + pl.Stations(8).completeTrolley + pl.Stations(9).completeTrolley) / (pl.Stations(26).totalTrolley + pl.Stations(27).totalTrolley + pl.Stations(6).totalTrolley + pl.Stations(7).totalTrolley + pl.Stations(8).totalTrolley + pl.Stations(9).totalTrolley) * 100) & "%"
                Case 10
                    Return Math.Round((pl.Stations(28).completeTrolley) / (pl.Stations(28).totalTrolley) * 100) & "%"
                Case 11
                    Return Math.Round((pl.Stations(29).completeTrolley + pl.Stations(11).completeTrolley + pl.Stations(14).completeTrolley) / (pl.Stations(29).totalTrolley + pl.Stations(11).totalTrolley + pl.Stations(14).totalTrolley) * 100) & "%"
                Case 12
                    Return Math.Round((pl.Stations(30).completeTrolley + pl.Stations(10).completeTrolley) / (pl.Stations(30).totalTrolley + pl.Stations(10).totalTrolley) * 100) & "%"
                Case 13
                    Return Math.Round((pl.Stations(31).completeTrolley + pl.Stations(12).completeTrolley) / (pl.Stations(31).totalTrolley + pl.Stations(12).totalTrolley) * 100) & "%"
                Case 14
                    Return Math.Round((pl.Stations(32).completeTrolley + pl.Stations(13).completeTrolley + pl.Stations(15).completeTrolley) / (pl.Stations(32).totalTrolley + pl.Stations(13).totalTrolley + pl.Stations(15).totalTrolley) * 100) & "%"
                Case 15
                    Return Math.Round((pl.Stations(33).completeTrolley + pl.Stations(34).completeTrolley) / (pl.Stations(33).totalTrolley + pl.Stations(34).totalTrolley) * 100) & "%"
                Case 16
                    Return Math.Round((pl.Stations(2).completeTrolley + pl.Stations(0).completeTrolley) / (pl.Stations(2).totalTrolley + pl.Stations(0).totalTrolley) * 100) & "%"
                Case 17
                    Dim i, TCL, TTL As Integer
                    For i = 0 To pl.Stations.Count - 1
                        TCL += pl.Stations(i).completeTrolley
                        TTL += pl.Stations(i).totalTrolley
                    Next
                    Return Math.Round((TCL / TTL) * 100) & "%"
                Case Else
                    Return "Error"
            End Select
        End If
    End Function
    Private Function GetLongestDate(ByVal Dates As List(Of Date)) As Date
        Dim i As Integer
        Dim result As Date
        result = Dates(0)
        For i = 1 To Dates.Count - 1
            If result < Dates(i) Then
                result = Dates(i)
            End If
        Next
        Return result
    End Function
    Private Function CalculateDate(ByVal row As Integer, ByVal pl As ProductionPlan) As String
        Dim dates As List(Of Date)
        If pl.pid = 0 Then
            Return "-"
        Else
            Select Case row
                Case 1
                    dates = New List(Of Date)
                    dates.Add(pl.Stations(3).lastTimeUpdated)
                    dates.Add(pl.Stations(1).lastTimeUpdated)
                    dates.Add(pl.Stations(35).lastTimeUpdated)
                    Return GetLongestDate(dates)
                Case 2
                    Return pl.Stations(16).lastTimeUpdated
                Case 3
                    Return pl.Stations(17).lastTimeUpdated
                Case 4
                    dates = New List(Of Date)
                    dates.Add(pl.Stations(18).lastTimeUpdated)
                    dates.Add(pl.Stations(19).lastTimeUpdated)
                    dates.Add(pl.Stations(5).lastTimeUpdated)
                    Return GetLongestDate(dates)
                Case 5
                    dates = New List(Of Date)
                    dates.Add(pl.Stations(20).lastTimeUpdated)
                    dates.Add(pl.Stations(21).lastTimeUpdated)
                    Return GetLongestDate(dates)
                Case 6
                    dates = New List(Of Date)
                    dates.Add(pl.Stations(22).lastTimeUpdated)
                    dates.Add(pl.Stations(23).lastTimeUpdated)
                    Return GetLongestDate(dates)
                Case 7
                    Return pl.Stations(24).lastTimeUpdated
                Case 8
                    dates = New List(Of Date)
                    dates.Add(pl.Stations(25).lastTimeUpdated)
                    dates.Add(pl.Stations(4).lastTimeUpdated)
                    Return GetLongestDate(dates)
                Case 9
                    dates = New List(Of Date)
                    dates.Add(pl.Stations(26).lastTimeUpdated)
                    dates.Add(pl.Stations(27).lastTimeUpdated)
                    dates.Add(pl.Stations(6).lastTimeUpdated)
                    dates.Add(pl.Stations(7).lastTimeUpdated)
                    dates.Add(pl.Stations(8).lastTimeUpdated)
                    dates.Add(pl.Stations(9).lastTimeUpdated)
                    Return GetLongestDate(dates)
                Case 10
                    Return pl.Stations(28).lastTimeUpdated
                Case 11
                    dates = New List(Of Date)
                    dates.Add(pl.Stations(29).lastTimeUpdated)
                    dates.Add(pl.Stations(11).lastTimeUpdated)
                    dates.Add(pl.Stations(14).lastTimeUpdated)
                    Return GetLongestDate(dates)
                Case 12
                    dates = New List(Of Date)
                    dates.Add(pl.Stations(30).lastTimeUpdated)
                    dates.Add(pl.Stations(10).lastTimeUpdated)
                    Return GetLongestDate(dates)
                Case 13
                    dates = New List(Of Date)
                    dates.Add(pl.Stations(31).lastTimeUpdated)
                    dates.Add(pl.Stations(12).lastTimeUpdated)
                    Return GetLongestDate(dates)
                Case 14
                    dates = New List(Of Date)
                    dates.Add(pl.Stations(32).lastTimeUpdated)
                    dates.Add(pl.Stations(13).lastTimeUpdated)
                    dates.Add(pl.Stations(15).lastTimeUpdated)
                    Return GetLongestDate(dates)
                Case 15
                    dates = New List(Of Date)
                    dates.Add(pl.Stations(33).lastTimeUpdated)
                    dates.Add(pl.Stations(34).lastTimeUpdated)
                    Return GetLongestDate(dates)
                Case 16
                    dates = New List(Of Date)
                    dates.Add(pl.Stations(2).lastTimeUpdated)
                    dates.Add(pl.Stations(0).lastTimeUpdated)
                    Return GetLongestDate(dates)
                Case Else
                    Return "Error"
            End Select
        End If
    End Function
    Private Sub UpdateDisplay()

        lblVar1.Text = lstPL(0).varian
        lblVar2.Text = lstPL(1).varian
        lblVar3.Text = lstPL(2).varian
        lblVar4.Text = lstPL(3).varian

        lblConsLot1.Text = lstPL(0).cons & "&nbsp; Lot : " & Integer.Parse(lstPL(0).lot)
        lblConsLot2.Text = lstPL(1).cons & "&nbsp; Lot : " & Integer.Parse(lstPL(1).lot)
        lblConsLot3.Text = lstPL(2).cons & "&nbsp; Lot : " & Integer.Parse(lstPL(2).lot)
        lblConsLot4.Text = lstPL(3).cons & "&nbsp; Lot : " & Integer.Parse(lstPL(3).lot)

        'Prouction Plan 1
        lblP1_1.Text = CalculateData(1, lstPL(0))
        lblP2_1.Text = CalculateData(2, lstPL(0))
        lblP3_1.Text = CalculateData(3, lstPL(0))
        lblP4_1.Text = CalculateData(4, lstPL(0))
        lblP5_1.Text = CalculateData(5, lstPL(0))
        lblP6_1.Text = CalculateData(6, lstPL(0))
        lblP7_1.Text = CalculateData(7, lstPL(0))
        lblP8_1.Text = CalculateData(8, lstPL(0))
        lblP9_1.Text = CalculateData(9, lstPL(0))
        lblP10_1.Text = CalculateData(10, lstPL(0))
        lblP11_1.Text = CalculateData(11, lstPL(0))
        lblP12_1.Text = CalculateData(12, lstPL(0))
        lblP13_1.Text = CalculateData(13, lstPL(0))
        lblP14_1.Text = CalculateData(14, lstPL(0))
        lblP15_1.Text = CalculateData(15, lstPL(0))
        lblP16_1.Text = CalculateData(16, lstPL(0))

        lblDT1_1.Text = CalculateDate(1, lstPL(0))
        lblDT2_1.Text = CalculateDate(2, lstPL(0))
        lblDT3_1.Text = CalculateDate(3, lstPL(0))
        lblDT4_1.Text = CalculateDate(4, lstPL(0))
        lblDT5_1.Text = CalculateDate(5, lstPL(0))
        lblDT6_1.Text = CalculateDate(6, lstPL(0))
        lblDT7_1.Text = CalculateDate(7, lstPL(0))
        lblDT8_1.Text = CalculateDate(8, lstPL(0))
        lblDT9_1.Text = CalculateDate(9, lstPL(0))
        lblDT10_1.Text = CalculateDate(10, lstPL(0))
        lblDT11_1.Text = CalculateDate(11, lstPL(0))
        lblDT12_1.Text = CalculateDate(12, lstPL(0))
        lblDT13_1.Text = CalculateDate(13, lstPL(0))
        lblDT14_1.Text = CalculateDate(14, lstPL(0))
        lblDT15_1.Text = CalculateDate(15, lstPL(0))
        lblDT16_1.Text = CalculateDate(16, lstPL(0))

        'Prouction Plan 2
        lblP1_2.Text = CalculateData(1, lstPL(1))
        lblP2_2.Text = CalculateData(2, lstPL(1))
        lblP3_2.Text = CalculateData(3, lstPL(1))
        lblP4_2.Text = CalculateData(4, lstPL(1))
        lblP5_2.Text = CalculateData(5, lstPL(1))
        lblP6_2.Text = CalculateData(6, lstPL(1))
        lblP7_2.Text = CalculateData(7, lstPL(1))
        lblP8_2.Text = CalculateData(8, lstPL(1))
        lblP9_2.Text = CalculateData(9, lstPL(1))
        lblP10_2.Text = CalculateData(10, lstPL(1))
        lblP11_2.Text = CalculateData(11, lstPL(1))
        lblP12_2.Text = CalculateData(12, lstPL(1))
        lblP13_2.Text = CalculateData(13, lstPL(1))
        lblP14_2.Text = CalculateData(14, lstPL(1))
        lblP15_2.Text = CalculateData(15, lstPL(1))
        lblP16_2.Text = CalculateData(16, lstPL(1))

        lblDT1_2.Text = CalculateDate(1, lstPL(1))
        lblDT2_2.Text = CalculateDate(2, lstPL(1))
        lblDT3_2.Text = CalculateDate(3, lstPL(1))
        lblDT4_2.Text = CalculateDate(4, lstPL(1))
        lblDT5_2.Text = CalculateDate(5, lstPL(1))
        lblDT6_2.Text = CalculateDate(6, lstPL(1))
        lblDT7_2.Text = CalculateDate(7, lstPL(1))
        lblDT8_2.Text = CalculateDate(8, lstPL(1))
        lblDT9_2.Text = CalculateDate(9, lstPL(1))
        lblDT10_2.Text = CalculateDate(10, lstPL(1))
        lblDT11_2.Text = CalculateDate(11, lstPL(1))
        lblDT12_2.Text = CalculateDate(12, lstPL(1))
        lblDT13_2.Text = CalculateDate(13, lstPL(1))
        lblDT14_2.Text = CalculateDate(14, lstPL(1))
        lblDT15_2.Text = CalculateDate(15, lstPL(1))
        lblDT16_2.Text = CalculateDate(16, lstPL(1))

        'Prouction Plan 3
        lblP1_3.Text = CalculateData(1, lstPL(2))
        lblP2_3.Text = CalculateData(2, lstPL(2))
        lblP3_3.Text = CalculateData(3, lstPL(2))
        lblP4_3.Text = CalculateData(4, lstPL(2))
        lblP5_3.Text = CalculateData(5, lstPL(2))
        lblP6_3.Text = CalculateData(6, lstPL(2))
        lblP7_3.Text = CalculateData(7, lstPL(2))
        lblP8_3.Text = CalculateData(8, lstPL(2))
        lblP9_3.Text = CalculateData(9, lstPL(2))
        lblP10_3.Text = CalculateData(10, lstPL(2))
        lblP11_3.Text = CalculateData(11, lstPL(2))
        lblP12_3.Text = CalculateData(12, lstPL(2))
        lblP13_3.Text = CalculateData(13, lstPL(2))
        lblP14_3.Text = CalculateData(14, lstPL(2))
        lblP15_3.Text = CalculateData(15, lstPL(2))
        lblP16_3.Text = CalculateData(16, lstPL(2))

        lblDT1_3.Text = CalculateDate(1, lstPL(2))
        lblDT2_3.Text = CalculateDate(2, lstPL(2))
        lblDT3_3.Text = CalculateDate(3, lstPL(2))
        lblDT4_3.Text = CalculateDate(4, lstPL(2))
        lblDT5_3.Text = CalculateDate(5, lstPL(2))
        lblDT6_3.Text = CalculateDate(6, lstPL(2))
        lblDT7_3.Text = CalculateDate(7, lstPL(2))
        lblDT8_3.Text = CalculateDate(8, lstPL(2))
        lblDT9_3.Text = CalculateDate(9, lstPL(2))
        lblDT10_3.Text = CalculateDate(10, lstPL(2))
        lblDT11_3.Text = CalculateDate(11, lstPL(2))
        lblDT12_3.Text = CalculateDate(12, lstPL(2))
        lblDT13_3.Text = CalculateDate(13, lstPL(2))
        lblDT14_3.Text = CalculateDate(14, lstPL(2))
        lblDT15_3.Text = CalculateDate(15, lstPL(2))
        lblDT16_3.Text = CalculateDate(16, lstPL(2))

        'Prouction Plan 4
        lblP1_4.Text = CalculateData(1, lstPL(3))
        lblP2_4.Text = CalculateData(2, lstPL(3))
        lblP3_4.Text = CalculateData(3, lstPL(3))
        lblP4_4.Text = CalculateData(4, lstPL(3))
        lblP5_4.Text = CalculateData(5, lstPL(3))
        lblP6_4.Text = CalculateData(6, lstPL(3))
        lblP7_4.Text = CalculateData(7, lstPL(3))
        lblP8_4.Text = CalculateData(8, lstPL(3))
        lblP9_4.Text = CalculateData(9, lstPL(3))
        lblP10_4.Text = CalculateData(10, lstPL(3))
        lblP11_4.Text = CalculateData(11, lstPL(3))
        lblP12_4.Text = CalculateData(12, lstPL(3))
        lblP13_4.Text = CalculateData(13, lstPL(3))
        lblP14_4.Text = CalculateData(14, lstPL(3))
        lblP15_4.Text = CalculateData(15, lstPL(3))
        lblP16_4.Text = CalculateData(16, lstPL(3))

        lblDT1_4.Text = CalculateDate(1, lstPL(3))
        lblDT2_4.Text = CalculateDate(2, lstPL(3))
        lblDT3_4.Text = CalculateDate(3, lstPL(3))
        lblDT4_4.Text = CalculateDate(4, lstPL(3))
        lblDT5_4.Text = CalculateDate(5, lstPL(3))
        lblDT6_4.Text = CalculateDate(6, lstPL(3))
        lblDT7_4.Text = CalculateDate(7, lstPL(3))
        lblDT8_4.Text = CalculateDate(8, lstPL(3))
        lblDT9_4.Text = CalculateDate(9, lstPL(3))
        lblDT10_4.Text = CalculateDate(10, lstPL(3))
        lblDT11_4.Text = CalculateDate(11, lstPL(3))
        lblDT12_4.Text = CalculateDate(12, lstPL(3))
        lblDT13_4.Text = CalculateDate(13, lstPL(3))
        lblDT14_4.Text = CalculateDate(14, lstPL(3))
        lblDT15_4.Text = CalculateDate(15, lstPL(3))
        lblDT16_4.Text = CalculateDate(16, lstPL(3))

        lblTotal1.Text = CalculateData(17, lstPL(0))
        lblTotal2.Text = CalculateData(17, lstPL(1))
        lblTotal3.Text = CalculateData(17, lstPL(2))
        lblTotal4.Text = CalculateData(17, lstPL(3))

    End Sub


Here's The Production Plan Class

Imports System.Data
Public Class ProductionPlan
    Public pid As Integer
    Public cons As String
    Public lot As String
    Public varian As String
    Public type As String
    Public Stations As New List(Of Station)
    Public dbCommand As OleDb.OleDbCommand
    Public dbReader As OleDb.OleDbDataReader
    Public Sub New()
        pid = 0
        cons = ""
        lot = "0"
        varian = "-"
    End Sub
    Public Sub GetStations()

        Dim st As Station
        dbCommand.CommandText = "SELECT ll.lb_loc_code,ll.lb_loc_type,COUNT(DISTINCT mot.Trolley) " & _
                                "FROM dbo.ML_on_Trolley mot RIGHT OUTER JOIN dbo.lb_loc ll ON " & _
                                "mot.[Type] = ll.lb_loc_type AND ll.lb_loc_code = mot.Station AND " & _
                                "mot.PID =" & pid & " " & _
                                "GROUP BY ll.lb_loc_code,ll.lb_loc_type ORDER BY ll.lb_loc_code"
        dbReader = dbCommand.ExecuteReader
        If dbReader.HasRows Then
            While dbReader.Read
                If dbReader.GetString(1) = type Then
                    st = New Station
                    st.dbCommand = dbCommand
                    st.dbReader = dbReader
                    st.id = dbReader.GetString(0)
                    st.totalTrolley = dbReader.GetInt32(2)
                    Stations.Add(st)
                End If
            End While
        End If
        dbReader.Close()
        Dim i As Integer
        For i = 0 To Stations.Count - 1
            Stations(i).GetCompleteTrolleys(pid)
            Stations(i).GetLastTimeUpdate(pid)
        Next
    End Sub
    Public Sub FinalizeMe()
        Me.Finalize()
    End Sub
End Class


Here's The Station Class
Imports Microsoft.VisualBasic
Imports System.Data
Public Class Station
    Public id As String
    Public name As String
    Public totalTrolley As Integer
    Public completeTrolley As Integer
    Public lastTimeUpdated As Date
    Public Trolleys As New List(Of Trolley)
    Public dbCommand As OleDb.OleDbCommand
    Public dbReader As OleDb.OleDbDataReader
    Private Sub GetTrolleys(ByVal PID As Integer)
        Dim trl As Trolley

        dbCommand.CommandText = "SELECT Trolley,count(part_number) FROM ML_on_trolley WHERE PID=" & PID & " AND Station='" & id & "' GROUP BY Trolley"
        dbReader = dbCommand.ExecuteReader
        If dbReader.HasRows Then
            While dbReader.Read
                trl = New Trolley
                trl.dbCommand = dbCommand
                trl.dbReader = dbReader
                trl.nama = dbReader.GetString(0)
                trl.totalItem = dbReader.GetInt32(1)
                Trolleys.Add(trl)
            End While
        End If
        dbReader.Close()
    End Sub
    Public Sub GetCompleteTrolleys(ByVal PID As Integer)
        GetTrolleys(PID)
        completeTrolley = 0
        Dim i As Integer
        For i = 0 To Trolleys.Count - 1
            If Trolleys(i).IsTrolleyComplete(PID, id) Then
                completeTrolley += 1
            End If
        Next
    End Sub
    Public Sub GetLastTimeUpdate(ByVal PID As Integer)
        dbCommand.CommandText = "SELECT TOP 1 dt_update FROM ML_on_Trolley WHERE PID=" & PID & " AND Station = '" & id & "' AND Status=1 ORDER BY dt_update DESC"
        dbReader = dbCommand.ExecuteReader
        If dbReader.HasRows Then
            dbReader.Read()
            lastTimeUpdated = dbReader.GetDateTime(0)
        Else
            lastTimeUpdated = Nothing
        End If
        dbReader.Close()
    End Sub
    Public Sub FinalizeMe()
        Me.Finalize()
    End Sub
End Class


Here's Trolley Class

Imports System.Data
Public Class Trolley
    Public nama As String
    Public trolleyType As String
    Public totalItem As Integer
    Public completeItem As Integer
    Public Items As New List(Of Item)
    Public dbCommand As OleDb.OleDbCommand
    Public dbReader As OleDb.OleDbDataReader
    Public Function IsTrolleyComplete(ByVal pid As Integer, ByVal station As String) As Boolean
        GetCompleteItems(pid, station)
        If totalItem = completeItem Then
            Return True
        Else
            Return False
        End If
    End Function
    Private Sub GetCompleteItems(ByVal PID As Integer, ByVal station As String)
        dbCommand.CommandText = "SELECT count(part_number) FROM ML_on_trolley WHERE PID=" & PID & " AND Station='" & station & "' AND Trolley='" & nama & "' AND Status=1"
        dbReader = dbCommand.ExecuteReader
        If dbReader.HasRows Then
            dbReader.Read()
            completeItem = dbReader.GetInt32(0)
        End If
        dbReader.Close()
    End Sub
    Public Sub FinalizeMe()
        Me.Finalize()
    End Sub
End Class


Thank's For the Suggestion
Posted
Updated 4-Oct-10 21:35pm
v5
Comments
Sandeep Mewara 4-Oct-10 12:26pm    
You cannot attach. Instead, just copy and paste it along with youe question.

use 'Improve Question' button. You will be able to edit your question then. Paste the code. Surround it by PRE tag and you are done.
Dalek Dave 5-Oct-10 3:35am    
Edited for Grammar and Readability.

post your code by just copy paste inside a code block. And if you have used your while loop for reading. while(reader.read()), Make sure that is terminated.
 
Share this answer
 
i Have updated my Question. Thanks
I need you help to solve this.
 
Share this answer
 
Comments
Goutam Patra 5-Oct-10 2:43am    
Dont puch answer. Use add comment link to reply to a specific answer.
But when i check on Task manager, i see that every time i open that page CPU Usage indicate to be 50% in average. Why is that. i am sure i always close and dispose all connection command and datareader...? :doh:
then i close it, it's back to normal.. (0%)? Why, i wonder....? help me..
 
Share this answer
 
v2
Is it because of lack of memory. I do clear List(of T) Variable...?
How to clean memory in browser then, so the AJAX works well.
Please Help me guys... :sigh:
 
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