|
-
Jan 3rd, 2012, 06:11 AM
#1
Thread Starter
Hyperactive Member
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
-
Jan 3rd, 2012, 06:24 AM
#2
Re: function not running completely (for next issue)... help...
Shouldn't this be:
For i = 0 To ListView1.ListItems.Count - 1
-
Jan 3rd, 2012, 07:50 AM
#3
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
-
Jan 3rd, 2012, 07:54 AM
#4
Thread Starter
Hyperactive Member
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...
-
Jan 3rd, 2012, 08:03 AM
#5
Re: function not running completely (for next issue)... help...
 Originally Posted by developerno1
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:
strquery2 = "Delete * FROM `" & tbname & "` WHERE `id`='" & ListView1.ListItems(i).Text & "' LIMIT 1;"
below the
vb Code:
cnMarket.Execute (strQuery)
and see if it makes a difference.
 Originally Posted by TysonLPrice
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
-
Jan 3rd, 2012, 08:19 AM
#6
Thread Starter
Hyperactive Member
Re: function not running completely (for next issue)... help...
it doesnt... :-( it just out of the sub after the 1st query execution...
-
Jan 3rd, 2012, 08:26 AM
#7
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.
-
Jan 3rd, 2012, 09:01 AM
#8
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
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
|