|
-
Oct 17th, 2006, 05:54 AM
#1
Thread Starter
Fanatic Member
reduce data retrieval time
is there any way to reduce time required to retrrive whole data from database and adding it to listview control.
i am having records about 3500 from 1 tables and for for each record it search for record in 2nd table and depending on 4to 5 conditons, i have to make color of each record dispalyed in list view control as diffrent color.
my database is in access and located on server.
it takes much time.
can you help me to reduce time ?
WHETHER YOU SUCCEED OR FAIL IS NOT AS IMPORTANT AS WHETHER YOU TRIED YOUR BEST 
-
Oct 17th, 2006, 05:58 AM
#2
Re: reduce data retrieval time
Try hiding the Listview when you are loading it, that should speed up things a bit. Then make it visible after it is loaded.
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
-
Oct 17th, 2006, 07:06 AM
#3
Re: reduce data retrieval time
Reducing the number of records loaded would help significantly.
Is it necessary to load all 3,500 records at once? Can these records be divided into categories and only those records meeting the category criteria get loaded?
-
Oct 17th, 2006, 07:22 AM
#4
Hyperactive Member
Re: reduce data retrieval time
A slow network can slow you down too.
-
Oct 17th, 2006, 09:29 AM
#5
Re: reduce data retrieval time
Its probably the multiple iterations and per record test that's slowing you down.
What are the conditions? The tables structures?
Maybe we can create a joined table (left join, where tabel1 is lefthand side) and in addition to the fields shown in the listview we can add other fields for each condition (checked against table2) and these fields will be used to format the listview output. That way you need to iterate through the recordset only once for adding the listitem and formatting it.
-
Oct 18th, 2006, 12:48 AM
#6
Thread Starter
Fanatic Member
Re: reduce data retrieval time
yes.
no of conditions per record is about 4 to 5.
and i can not use any join condition as i have to look up a whole table record in another table.
WHETHER YOU SUCCEED OR FAIL IS NOT AS IMPORTANT AS WHETHER YOU TRIED YOUR BEST 
-
Oct 18th, 2006, 01:11 AM
#7
Re: reduce data retrieval time
what's the table structure?
post your current code
-
Oct 18th, 2006, 01:16 AM
#8
Thread Starter
Fanatic Member
Re: reduce data retrieval time
my code is so long.
VB Code:
rs.Open strsql, conn_proc.con, 3, 3
While rs.EOF = False
Set t1 = listv1.ListItems.Add(Text:=rs!proj)
i = 0
ReDim cnt(rs.Fields.Count - 7) As Long
For Each J In cnt
i = i + 1
If rs.Fields(i).Type = adDate Then
t1.SubItems(i) = Trim(" " & Format(rs.Fields(i).Value, "dd-mmm-yyyy") & " ")
Else
t1.SubItems(i) = Trim(" " & rs.Fields(i).Value & " ")
End If
If i = 9 Then
'If Val(Trim(" " & rs!cflag & " ")) = 0 Then
t1.ListSubItems(9).ForeColor = RGB(255, 0, 0)
'If Val(Trim(" " & rs!bal & " ")) = 0 Then t1.ListSubItems(9).ForeColor = &H8000&
If Val(Trim(" " & rs!rqty & " ")) > Val(Trim(" " & rs!bal & " ")) And Val(Trim(" " & rs!bal & " ")) > 0 Then t1.ListSubItems(9).ForeColor = RGB(0, 0, 255)
End If
Next
' If Val(Trim(" " & rs!cflag & " ")) = 0 Then t1.Selected = False
' If Val(Trim(" " & rs!cflag & " ")) = 1 Then
' t1.Checked = True
' End If
schno = ""
If rs!reci = "" Then
t1.ListSubItems(1).ForeColor = RGB(255, 0, 250)
End If
act1 = ""
remdate = ""
'*************************8
srno = rs!srno
rno = rs!rno
rs1.Open "select * from follow_up where srno = " & srno & " and rno = '" & rno & "' order by id desc", conn_proc.con, 3, 3
If rs1.RecordCount > 0 Then
If rs1!ddate <> "" Then r1 = Format(rs1!ddate, "dd-mmm-yyyy")
If rs1!remdate <> "" Then remdate = Format(rs1!remdate, "dd-mmm-yyyy")
If rs1!act <> "" Then act1 = Trim(" " & rs1!act)
If rs1!schno <> "" Then schno = Trim(" " & rs1!schno)
If rs1!pname <> "" Then pname = Trim(" " & rs1!pname)
t1.SubItems(15) = pname
actprev = ""
rs1.MoveNext
If rs1.EOF = False Then
actprev = Trim(" " & rs1!act)
rs1.MovePrevious
End If
If actprev = "" Then actprev = act1
End If
'If LCase(Trim(act1)) = "sch" Or LCase(Trim(act1)) = "po" Then
colchange = ""
If schno <> "" Then
If ((LCase(actprev) <> "enquiry") Or (LCase(act1) = "sch" Or LCase(act1) = "po")) Then
colchange = &H8000&
End If
End If
If Val(Trim(" " & rs!EMER)) = 1 Or Val(Trim(" " & rs!pref)) = 1 Then
colchange = &HFAAF4
End If
If Val(Trim(" " & rs!rtype)) = 1 Then
colchange = &H8582F0
End If
If Val(Trim(" " & rs!descr)) = 1 Then
colchange = &HC0C000
End If
If colchange <> "" Then
For ij = 1 To t1.ListSubItems.Count
t1.ListSubItems(ij).ForeColor = colchange
Next
t1.ForeColor = colchange
End If
rs1.Close
'**************************8
' r1 = get_last_rcd(rs!rno, rs!srno)
If r1 <> "" Then t1.SubItems(14) = r1
t1.SubItems(13) = schno
If LCase(frmlogin.cat) = "power user" Or LCase(frmlogin.cat) = LCase("administrator") Or LCase(frmlogin.cat) = LCase("purchase department") Then
t1.SubItems(12) = act1
Else
t1.SubItems(12) = ""
End If
If remdate <> "" Then t1.SubItems(10) = Format(rs!ddate, "dd-mmm-yyyy")
rs.MoveNext
Wend
WHETHER YOU SUCCEED OR FAIL IS NOT AS IMPORTANT AS WHETHER YOU TRIED YOUR BEST 
-
Oct 18th, 2006, 01:21 AM
#9
Re: reduce data retrieval time
what's the sql on line 1?
rs.Open strsql, conn_proc.con, 3, 3
-
Oct 18th, 2006, 01:26 AM
#10
Re: reduce data retrieval time
And the table structures (field names, data types) pls.
-
Oct 18th, 2006, 01:33 AM
#11
PowerPoster
Re: reduce data retrieval time
shukla, have you tried GetRows yet?
-
Oct 18th, 2006, 02:45 AM
#12
Thread Starter
Fanatic Member
Re: reduce data retrieval time
i have not tried GetRows method.
can you tell me about it.
VB Code:
strsql = "select proj,req.rno,req.dt,item,req_details.size1,reason,rqty,req_details.unit1,bal,edate,ddate,srno,cflag,reci,emer,rtype,descr,pref from req,req_details where req.rno = req_details.rno and bal > 0 and sanc <> '' and val(canreq) <> 1 "
WHETHER YOU SUCCEED OR FAIL IS NOT AS IMPORTANT AS WHETHER YOU TRIED YOUR BEST 
-
Oct 18th, 2006, 02:53 AM
#13
PowerPoster
Re: reduce data retrieval time
first i need you to identify each field with table name first .. eg. like you have with a couple of them... table.FieldName.
-
Oct 18th, 2006, 02:57 AM
#14
Thread Starter
Fanatic Member
Re: reduce data retrieval time
req is first table then req_details is sencond and third is follow_up
for each record in req.thre is 1 or more records and for each record in req_details there i s or not record in follow_up
WHETHER YOU SUCCEED OR FAIL IS NOT AS IMPORTANT AS WHETHER YOU TRIED YOUR BEST 
-
Oct 18th, 2006, 04:12 AM
#15
Re: reduce data retrieval time
Is this an access database? If so, could you please zip up and post the database
-
Oct 18th, 2006, 04:22 AM
#16
Thread Starter
Fanatic Member
Re: reduce data retrieval time
i can not because my organisation will not allow for it.
WHETHER YOU SUCCEED OR FAIL IS NOT AS IMPORTANT AS WHETHER YOU TRIED YOUR BEST 
-
Nov 2nd, 2006, 04:27 AM
#17
Thread Starter
Fanatic Member
Re: reduce data retrieval time
please tell me if anyone can suggest me.
WHETHER YOU SUCCEED OR FAIL IS NOT AS IMPORTANT AS WHETHER YOU TRIED YOUR BEST 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|