Hi there
i am working on Medical Billing project in vb.net
I made Login form and it was run with user name and password.
but i also made radio button selection on top for doctor , staff and for admin.
so my question is how i connect the useid,password chk with particular selection tht match radio buttons selection according to database.

this is my login code

Public Class frmLogin
    Dim bm As BindingManagerBase
    Private Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub btnlogon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogon.Click
        Dim wd As Welcomedoctor = New Welcomedoctor
        Me.TbluserTableAdapter.SearchBy(Me.ProjectDataSet.tbluser, txtuserid.Text, txtpassword.Text)

        bm = Me.BindingContext(Me.ProjectDataSet, "tbluser")
        If Me.ProjectDataSet.tbluser.Rows.Count > 0 Then
            MessageBox.Show("Valid")
            wd.test(Me)
            wd.Show()
        Else
            MessageBox.Show("Invalid")
        End If
    End Sub

    Private Sub btncancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncancel.Click
        Me.Close()
    End Sub

    Public Sub runLoad()
        'TODO: This line of code loads data into the 'ProjectDataSet.tbluser' table. You can move, or remove it, as needed.
        Me.TbluserTableAdapter.Fill(Me.ProjectDataSet.tbluser)
    End Sub
    'Public Class login
    '    Inherits System.Windows.Forms.Form
    '    Dim iCount As Integer
    '    Dim frmMain As New Welcomeadmin

    '    Private Sub btnlogon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogon.Click
    '        'Dim ConString As String = "Provider=Microsoft.jet.OLEDB.4.0;Password;userid=Admin;Data Source=C:\project.mdb"
    '        'Dim DBCon As New OleDb.OleDbConnection(ConString)
    '        'g_login = Me.txtuserid.Text
    '        'Dim strPassword As String = Me.txtpassword.Text
    '        'If g_login = "" Or strPassword = "" Then
    '        '    MessageBox.Show("You are missing Information.Please check both UserId and Password fields are filed out.", "Missing Info")
    '        '    Me.txtuserid.Focus()
    '        '    Return
    '        'End If

    '        'Dim strsql As String = "SELECT [userid],[password] FROM tbluser WHERE [userid]='" & g_login & "'"
    '        'Dim cm As New OleDb.OleDbCommand(strsql, DBCon)
    '        'Dim dr As OleDb.OleDbDataReader
    '        'Dim valid As Boolean = False
    '        'Dim HasRows As Boolean = False
    '        'Try
    '        '    DBCon.Open()
    '        '    dr = cm.ExecuteReader
    '        '    If dr.HasRows Then
    '        '        While dr.Read
    '        '            If strPassword = dr.Item("password") Then
    '        '                valid = True
    '        '            End If
    '        '        End While
    '        '        HasRows = True
    '        '    End If
    '        '    dr.Close()

    '        'Catch exO As OleDb.OleDbException
    '        '    MessageBox.Show(exO.Message)
    '        'Catch ex As Exception
    '        '    MessageBox.Show(ex.Message)
    '        'Finally
    '        '    If DBCon.State = ConnectionState.Open Then
    '        '        DBCon.Close()
    '        '    End If
    '        '    cm = Nothing
    '        '    dr = Nothing
    '        '    DBCon.Dispose()
    '        '    GC.Collect()
    '        'End Try

    '        'iCount = iCount + 1
    '        'If valid = True Then
    '        '    Me.Hide()
    '        '    frmMain.Show()
    '        'ElseIf iCount = 3 Then
    '        '    MessageBox.Show("Contact Admin !", "Invalid Info")
    '        '    Me.Close()
    '        'ElseIf HasRows = False Then
    '        '    MessageBox.Show("Invalid User Id,try again !", "Invalid Info")
    '        '    Me.txtuserid.Focus()
    '        '    Me.txtuserid.Text = ""
    '        '    Me.txtpassword.Text = ""
    '        'Else
    '        '    MessageBox.Show("Invalid Password, try again !", "Invalid Info")
    '        '    Me.txtpassword.Focus()
    '        '    Me.txtpassword.Text = ""
    '        'End If

    '    End Sub

    '    Private Sub btncancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncancel.Click
    '        Me.Close()
    '    End Sub


    'End Class







    'Private Sub SearchByToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchByToolStripButton.Click
    '    Try
    '        Me.TbluserTableAdapter.SearchBy(Me.ProjectDataSet.tbluser, txtuserid.Text, txtpassword.Text)
    '    Catch ex As System.Exception
    '        System.Windows.Forms.MessageBox.Show(ex.Message)
    '    End Try

    'End Sub

    End Class

Can you describe your table structure?

i have tableuser with userid,password,function
function is the user identification like user is Doctor or Admin or Staff
i use 3 radio buttons for this function with selection..now i want to check when user select the particular selection on form and whatever in database ..they have to match and give access to go further in login page.

thx for help.

ok why don't you do something like this:

SELECT Password FROM tableuser WHERE UserID = 123456 and function = 'Staff'

and then compare the result of that with the text field for password.

if you don't know how to do it, ask very specific question as to what you don't know.

Example "how do I write the condition for if statement?".

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.