23-05-17, 12:49 PM
ماهو الخطأ في هذا الloop لانه لا يعمل وما الفرق عندما اضع الloop يبدأ ب 1 أو ب0 لاني عندما اضع 0 في هذا المثال يعمل الloop ولكن لمرة واحدة فقط وعندما اضع
1 لا يعمل اصلا
Dim i As Integer
For i = 1 To rest_sum < sum2
Dim comselect3 As New SqlCommand(" select p_id from table1 where p_id<>0 and counted=0 order by p_id", con)
Dim d3 As New DataSet
Dim t3 As New SqlDataAdapter
t3.SelectCommand = comselect3
t3.Fill(d3, "table1 ")
If d3.Tables("table1 ").Rows.Count <> 0 Then
p_id = d3.Tables("table1 ").Rows(0)(0)
End If
Dim comupdate As New SqlCommand("update table1 set pay_status=1 , counted=1 where id='" & Val(TextBox2.Text) & "' and P_id='" & P_id & "'", con)
con.Open()
comupdate.ExecuteNonQuery()
con.Close()
If con.State = ConnectionState.Open Then con.Close()
rest_sum = Val(rest_sum) - Val(sum2)
If rest_sum < sum2 Then
Exit For
End If
Next
1 لا يعمل اصلا
Dim i As Integer
For i = 1 To rest_sum < sum2
Dim comselect3 As New SqlCommand(" select p_id from table1 where p_id<>0 and counted=0 order by p_id", con)
Dim d3 As New DataSet
Dim t3 As New SqlDataAdapter
t3.SelectCommand = comselect3
t3.Fill(d3, "table1 ")
If d3.Tables("table1 ").Rows.Count <> 0 Then
p_id = d3.Tables("table1 ").Rows(0)(0)
End If
Dim comupdate As New SqlCommand("update table1 set pay_status=1 , counted=1 where id='" & Val(TextBox2.Text) & "' and P_id='" & P_id & "'", con)
con.Open()
comupdate.ExecuteNonQuery()
con.Close()
If con.State = ConnectionState.Open Then con.Close()
rest_sum = Val(rest_sum) - Val(sum2)
If rest_sum < sum2 Then
Exit For
End If
Next