CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2009
    Posts
    1

    Vb6.0 application not responding

    I am reading Excel File in Vb6.0, which has 2 sheets. Sheet1 contains 30,000 records and Sheet2 contains 30,000. I want to compare records present in both sheets.

    Query1 = "SELECT * FROM [Sheet1$] order by LOV_TYPE,LOV_VALUE,LIC,PARENT_LIC,LANGUAGE_ID" 'Sorting Order
    sconn1 = "DRIVER=Microsoft Excel Driver (*.xls);" & "DBQ=" & ExcelFileName
    Dim rs1 As ADODB.Recordset
    Set rs1 = New ADODB.Recordset
    rs1.CursorLocation = adUseClient
    rs1.CursorType = adOpenKeyset
    rs1.LockType = adLockBatchOptimistic
    rs1.Open Query1, sconn1
    sheet1Array = rs1.GetRows

    Query2 = "SELECT * FROM [Sheet2$] order by LOV_TYPE,LOV_VALUE,LIC,PARENT_LIC,LANGUAGE_ID" 'Sorting Order
    sconn2 = "DRIVER=Microsoft Excel Driver (*.xls);" & "DBQ=" & ExcelFileName
    Dim rs2 As ADODB.Recordset
    Set rs2 = New ADODB.Recordset
    rs2.CursorLocation = adUseClient
    rs2.CursorType = adOpenKeyset
    rs2.LockType = adLockBatchOptimistic
    rs2.Open Query2, sconn2
    sheet2Array = rs2.GetRows
    dim matchedflag as integer
    for Sheet1row=0 to rs1.recordcount then
    matchedflag=0
    for sheet2row=0 to rs2.recordcount then
    if sheet2array(0,sheet2row)=sheet1array(0,sheet1row) and sheet2array(1,sheet2row)=sheet1array(1,sheet1row) and sheet2array(2,sheet2row)=sheet1array(2,sheet1row) and sheet2array(3,sheet2row)=sheet1array(3,sheet1row) and sheet2array(4,sheet2row)=sheet1array(4,sheet1row) then
    MatchedFlag=1
    end if
    next sheet2row
    if matchedflag=0 'sheet1 Record not found in sheet2
    'coding to write this record into new excel sheet
    end if
    next sheet1row


    Both Excel sheet(sheet1, sheet2) contains same column names, but data might be different. I have to find out the mismatched records and update the same in new excel sheet. While running the above code it is not responding and showing white(blank) screen.After 15 minutes the output is coming. I want to improve the performance. Please help ASAP. There may be more than 30,000 records in each sheet. Please provide the code to retrieve the data from excel sheet by specifying path of the excel file name(without creating DSN), sheet name and how to compare two records.

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Vb6.0 application not responding

    Please use CODE TAGS.

    Where did you find that? This doesn't make ANY sense, and shouldn't work
    Code:
    for Sheet1row=0 to rs1.recordcount then
    matchedflag=0
    for sheet2row=0 to rs2.recordcount then
    if sheet2array(0,sheet2row)=sheet1array(0,sheet1row) and sheet2array(1,sheet2row)=sheet1array(1,sheet1row) and sheet2array(2,sheet2row)=sheet1array(2,sheet1row) and sheet2array(3,sheet2row)=sheet1array(3,sheet1row) and sheet2array(4,sheet2row)=sheet1array(4,sheet1row) then
    MatchedFlag=1
    end if
    next sheet2row
    Not to mention that we don't WRITE code to solve your problems. We can help you if you want to help yourself
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured