Advertisement

11.10.2004 at 01:19AM PST, ID: 21201290
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

Running very Slow

Asked by william43 in Visual Basic Programming

Tags: ,

Hi,
I have a very difficult solution(for me) need your help. I created the following code for my application. it run as wht i want but the problem is the process is very slow. it takes more than 10 seconds. Could you pls help me to make the code run much faster? here is my codes:

Dim rst As ADODB.Recordset
Dim query As String
Dim query1 As String
Dim x As Variant

x = Null
'Find Ident No
If Len(cbIdentNo) <> 0 Then
    x = "[IdentMaster].[IdentNo]=""" & cbIdentNo & """"
End If
'Find Machine Manufacturer ID
If Not IsNull(cbManufacturer) And cbManufacturer <> Empty Then
    If Not IsNull(x) Then
        x = x & " and " & "[MachineManufacturerID]=" & tbManufacturer.Text
    Else
        x = "[MachineManufacturerID]=" & tbManufacturer.Text  
    End If
End If

query = "SELECT IdentMaster.IdentNo, ArtMachineManufacturer.MachineManufacturerID , ArtMachineType.MachineTypeID" _
& " FROM IdentMaster, ArtMachineManufacturer" _
& " where " & x & " order by IdentMaster.IdentNo" _
& " WITH OWNERACCESS OPTION"

Set rst = New ADODB.Recordset
rst.CursorType = adOpenStatic
rst.Open query, conn, , , adCmdText

conn.Execute "Delete * from Result"
'retrieve Result field.
Dim rst1 As ADODB.Recordset
Set rst1 = New ADODB.Recordset
rst1.Open "Select * from Result", conn, adOpenKeyset, adLockOptimistic, adCmdText
Dim intCount, i As Integer
    rst.MoveLast
    intCount = rst.RecordCount
    rst.MoveFirst
    Do Until rst.EOF
        Dim rst2 As ADODB.Recordset
        Set rst2 = New ADODB.Recordset
        rst2.Open "select IdentNo from result where identno =""" & rst!IdentNo & """", conn, adOpenKeyset, adLockOptimistic, adCmdText
        If rst2.RecordCount = 0 Then
            With rst1
            .AddNew
            !IdentNo = rst!IdentNo
            !MachineManufacturerID = rst!MachineManufacturerID
            !MachineTypeID = rst!MachineTypeID
            !GroupID = rst!GroupID
            !product = rst!product
            !Dimension = FindDimension(rst!IdentNo)
            !ToolApplicationID = rst!ToolApplicationID
            .Update
            End With
        End If
        rst.MoveNext
    Loop
    'rst1.Update
End If

Function FindDimension(IdentNo) As String
Dim rst As New ADODB.Recordset
Dim connect_string As String
connect_string = Connection()

With rst
    .CursorLocation = adUseServer
    .CursorType = adOpenKeyset
    .Open "IdentMaster", connect_string, adOpenKeyset, adLockOptimistic, adCmdTableDirect
    .Index = "PrimaryKey"
End With
'rst.MoveFirst
rst.Seek Array(IdentNo)
If Not rst.EOF Then
    Select Case rst!categorytype
        Case "KSN"
        FindDimension = rst!D & "x" & rst!B & "x" & rst!dSmall & " Z=" & rst!Z & " NL/DKN=" & rst!NL & "/" & rst!DKN
    End Select
End If

rst.Close
Set rst = Nothing
End Function

Thank you.
Beginner.Start Free Trial
[+][-]11.10.2004 at 04:04AM PST, ID: 12543165

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]11.10.2004 at 04:05AM PST, ID: 12543173

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Visual Basic Programming
Tags: slow, adopenkeyset
Sign Up Now!
Solution Provided By: anv
Participating Experts: 2
Solution Grade: A
 
 
[+][-]11.17.2004 at 04:16AM PST, ID: 12603268

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]12.13.2004 at 01:04PM PST, ID: 12813154

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]12.20.2004 at 07:23PM PST, ID: 12872810

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-42