Hi All,

Got an issue that I know is quite common and read through lots of guides but cant see where I am going wrong. Got the code below which when form is loaded goes and grabs user from a table of usernames and puts them against a combo box so people can select user from a drop down list:

        Private Sub Login_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If User = True Then
                lblCurrentUser.Text = "The Current User is: " & UserName
            Else
                lblCurrentUser.Text = "No Active User"
            End If
            SQL = "SELECT User FROM Username ORDER BY User"
            da = New OleDb.OleDbDataAdapter(SQL, con)
            Dim ds As New DataSet
            da.Fill(ds, "Username")
            cbUser.DataSource = ds.Tables("UserName")
            cbUser.DisplayMember = "User"
            cbUser.ValueMember = "User"
            con.Close()
        End Sub

The user fills out some data and then inputs this into another table in the same database, exerything goes fine including the lookup for the pin number in the code below compared to the user, the only think is it displays the "System.Data.DataRowView". I cant see why, it has got the write user name cause when it queries the database for the pin it works when its correct and not when wrong pin is entered:

    Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        SQL = "SELECT UserPin FROM Username WHERE User = '" & cbUser.SelectedValue & "' "
        MsgBox(cbUser.SelectedItem.ToString)
        If Not con.State = ConnectionState.Open Then
            con.Open()
        End If
        cmd = New OleDb.OleDbCommand(SQL, con)
        dr = cmd.ExecuteReader
        While dr.Read
            Userpin = dr.Item("Userpin")
        End While

        If Userpin = Nothing Then
            MsgBox("Invalid User", MsgBoxStyle.Critical)
        End If

        If Userpin <> tbPin.Text Then
            MsgBox("Invalid Pin for " & cbUser.SelectedItem.ToString, MsgBoxStyle.Critical)
        End If

        If tbPin.Text = Userpin Then
            If tbMileage.Text = Nothing Then
                MsgBox("No Mileage Entered", MsgBoxStyle.Critical)
            ElseIf Duty = Nothing Then
                MsgBox("Duty Not Stated", MsgBoxStyle.Critical)
            ElseIf Vehicle = Nothing Then
                MsgBox("Vehicle Not Stated", MsgBoxStyle.Critical)
            Else
                SQL = "INSERT INTO UserLog VALUES('" & Date.Now & "', '" & Me.cbUser.selecteditem.tostring & "', 'Sign On', '" & Duty & "', '" & Vehicle & "', '" & tbMileage.Text & "')"
                cmd = New OleDb.OleDbCommand(SQL, con)
                cmd.ExecuteNonQuery()

                SQL = "INSERT INTO Activity VALUES('" & Date.Now & "', '" & Me.cbUser.selecteditem.tostring & "', 'Sign On')"
                cmd = New OleDb.OleDbCommand(SQL, con)
                cmd.ExecuteNonQuery()
                con.Close()

                User = True
                UserName = Me.cbUser.selecteditem.tostring
                MsgBox(UserName & " has logged on", MsgBoxStyle.Information)
                Me.Close()
                MainMenu.MdiParent = Main
                MainMenu.Show()
            End If
        End If
    End Sub

HELP!!! this is really annoying me now lol.

Cheers for your help in advance.
Will

Just completely ignore me, noticed the error on line 3, SelectedItem not SelectedValue.

Grrr...
Cheers
Will

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.