Form Misread

EStallworth

Well-known member
Joined
Aug 14, 2006
Messages
75
Location
Destin, FL
Programming Experience
Beginner
I have an application that uses a dataset to collect user information(login and password). I have written a loop that searches the datatable. All was working fine until I reseeded the table. This is my original loop:

VB.NET:
For i As Integer = 0 To Me.UserDataSet.Users.Rows.Count - 1
            If user = Me.UserDataSet.Users.Rows(i).Item("UserName").ToString AndAlso password = Me.UserDataSet.Users.Rows(i).Item("Password").ToString Then
                authentication = True
                Me.Close()
            Else
                MsgBox("You are not an authorized user of this program.  Please step away from the PC.")
                End
            End If
        Next


Now that I have reseeded the table, all the information has been restored as it was before but now I have to use:

VB.NET:
For i As Integer = 1 To Me.UserDataSet.Users.Rows.Count - 1
            If user = Me.UserDataSet.Users.Rows(i).Item("UserName").ToString AndAlso password = Me.UserDataSet.Users.Rows(i).Item("Password").ToString Then
                authentication = True
                Me.Close()
            Else
                MsgBox("You are not an authorized user of this program.  Please step away from the PC.")
                End
            End If
        Next

And this will only allow me to read the second entry within the table (there are only 2). There are 3 columns (ID, UserName, Password) and 2 rows. Can anyone see where my problem is or why it will not read all the entries in the database(SQL)?¿ Any help would be appreciated. I have ideas of work arounds but I would really like to know just why this isn't working correctly.

Thank goodness it's Friday! I don't have to deal with it anymore until the dreaded Monday! Everyone have a good weekend!

I just realized I probably posted this in the wrong place. Admins I apologize. I feel like the users I have to deal with now! AHHHHHHHHHH!
 
Each time u go for FOR LOOP reset the dataset and again reload into it with fresh data


always start integer with "0(Zero)" in for loop , if u use from "1" it never takes the zeroth row in dataset

instead using u r format try this

For i As Integer = 0 To Me.UserDataSet.tables(0).rows.count-1
If user = Me.UserDataSet.tables(0).Rows(i).Itemarray(1).tostring AndAlso password = Me.UserDataSet.tables(0).Rows(i).Itemarray(2).ToString Then
authentication = True
Me.Close()
Else
MsgBox("You are not an authorized user of this program. Please step away from the PC.")
End
End If
Next

BYe !
 
Back
Top