Results 1 to 8 of 8

Thread: function not running completely (for next issue)... help...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2005
    Posts
    305

    function not running completely (for next issue)... help...

    hi guys ive the following sub which updates a mysql table... i call when a button is pressed to move all the data listed in the listview to be transferred from one table to another... now when i run this, while debugging i found that the first query gets executed and it returns back to continue the rest of the code in the commandbutton instead of executing the second query and then looping in the for next loop... please guide me on the issue.. hope im clear enough in explaining it...
    cnmarket is the adodb connection....

    Code:
    Public Sub updatetable()
    Dim strquery2 As String
    Call OpenDatabase
    Set rsQuery = New ADODB.Recordset
        Dim strQuery As String
        Dim tbname As String
        tbname = GetSetting(App.EXEName, "table", "name", "http_jobs")
        For i = 1 To ListView1.ListItems.Count
        strQuery = "INSERT INTO `testtable` SELECT * FROM `" & tbname & "` WHERE `id`='" & ListView1.ListItems(i).Text & "' LIMIT 1;"
    strquery2 = "Delete * FROM `" & tbname & "` WHERE `id`='" & ListView1.ListItems(i).Text & "' LIMIT 1;"
    cnMarket.Execute (strQuery) 'EXECUTED
       cnMarket.Execute (strquery2) 'DOESNT REACH HERE,JUMPS BACK...
        Next i
    End Sub

  2. #2
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    Re: function not running completely (for next issue)... help...

    Shouldn't this be:

    For i = 0 To ListView1.ListItems.Count - 1

  3. #3
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: function not running completely (for next issue)... help...

    What error are you receiving?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2005
    Posts
    305

    Re: function not running completely (for next issue)... help...

    there's no error but it is making the changes in only the first record an rest remain unaffected. also the 2nd query(deletion) also doesnt occur, only the 1st query is running...

  5. #5
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: function not running completely (for next issue)... help...

    Quote Originally Posted by developerno1 View Post
    there's no error but it is making the changes in only the first record an rest remain unaffected. also the 2nd query(deletion) also doesnt occur, only the 1st query is running...
    Try moving

    vb Code:
    1. strquery2 = "Delete * FROM `" & tbname & "` WHERE `id`='" & ListView1.ListItems(i).Text & "' LIMIT 1;"

    below the

    vb Code:
    1. cnMarket.Execute (strQuery)

    and see if it makes a difference.

    Quote Originally Posted by TysonLPrice View Post
    Shouldn't this be:

    For i = 0 To ListView1.ListItems.Count - 1
    That depends on if he is testing for the index or not.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2005
    Posts
    305

    Re: function not running completely (for next issue)... help...

    it doesnt... :-( it just out of the sub after the 1st query execution...

  7. #7
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: function not running completely (for next issue)... help...

    The syntax of the Delete SQL Statement is incorrect (There's no * in a DELETE)
    Code:
    strquery2 = "Delete FROM '" & tbname & "` WHERE `id`='" & ListView1.ListItems(i).Text & "' & "' LIMIT 1;"
    Last edited by Doogle; Jan 3rd, 2012 at 08:31 AM.

  8. #8
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: function not running completely (for next issue)... help...

    I suspect there is an error that's happening... and you aren't catching it. Try right-clicking, select Toggle -> error handle (think this is right, it's been a while since I've been in VB6) ... and select Break on all errors.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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