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
Re: function not running completely (for next issue)... help...
Shouldn't this be:
For i = 0 To ListView1.ListItems.Count - 1
Re: function not running completely (for next issue)... help...
What error are you receiving?
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...
Re: function not running completely (for next issue)... help...
Quote:
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.
Quote:
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.
Re: function not running completely (for next issue)... help...
it doesnt... :-( it just out of the sub after the 1st query execution...
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;"
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