Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why my logic is not correct?
Message
De
25/06/2007 10:57:20
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
 
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
01235339
Message ID:
01235344
Vues:
17
This message has been marked as the solution to the initial question of the thread.
Gregorio,
The problem is with this line of code:
For Each drdepts In depts_changes.Table.Rows
What you are doing is pointing to the table that the dataview is based on, which is the unfiltered datasource. I have done this before, so that is why I know... :-)

Try changing drdepts from a DataRow to a DataRowView, and change the line I mentioned before to:
For Each drdepts In depts_changes
>Hi all!
>
>I got the following code. The problem I create a dataview that going to filter all my rows that are true and delete the record in the backend, when I run the code it goes throw all the rows instead of the rows market true.
>
>
>Private Sub Del_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Del_btn.Click
>        Dim error_msg As String
>        Dim depts_changes As New DataView
>        Dim drdepts As DataRow
>        Dim I As Integer
>        Dim Y As Integer
>        error_msg = "Some of the record selected is been using in other"
>        error_msg = error_msg + vbCrLf + "databases:"
>        depts_changes.Table = Me.Depts_LookupDataSet.Tables(0)
>        depts_changes.RowFilter = "Lsele = True"
>        For Each drdepts In depts_changes.Table.Rows
>            Try
>                Me.Dept_Delete_SQLCMD.Parameters("@Dept_Pk").Value = drdepts("DepartmentsPK")
>                'Me.Dept_Delete_SQLCMD.Parameters("@Return_Value").Value = 0
>                Me.Uan_SqlConnection.Open()
>                Me.Dept_Delete_SQLCMD.ExecuteNonQuery()
>                Me.Uan_SqlConnection.Close()
>                If Me.Dept_Delete_SQLCMD.Parameters("@Return_Value").Value = True Then
>                    I = I + 1
>                    error_msg = error_msg + vbCrLf + drdepts("DepartmentAbbreviation") + "    " + drdepts("DepartmentName")
>                Else
>                    Y = Y + 1
>                End If
>            Catch ex As Exception
>                MessageBox.Show(ex.ToString)
>                Me.Uan_SqlConnection.Close()
>            End Try
>        Next
>        If I > 0 Then
>            MessageBox.Show(error_msg)
>        End If
>        If Y > 0 Then
>            Me.MSG_TXT.Text = CType(Y, String) + " record(s) has been deleted"
>        End If
>        Me.Fill_Parent_Grid()
>
>    End Sub
>
Very fitting: http://xkcd.com/386/
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform