Brian

Brian

  • NA
  • 1
  • 0

Passing Variable

Nov 11 2009 5:44 PM
Hi folks,

New to winforms. I have managed to get a winform login form (Form1) running where i have users authenticate against a username/password that is stored in a SQL Server 2005 Database. If they authenticate, then Form2 will show, if not, an incorrect username/password message is displayed.

On form2, i have created a datagrid which shows all data from a table in SQL Server. It shows all employee course history data for all employees.

I would like when the user logs on, that the datagrid only shows the records in the datagrid for that logged in user only and not the records for all employees.

How can i take the input details (username/password) from the current user logged in and only show them their records in the grid on Form2.

Basically, I would like to pass the username that the user typed in Form1 to Form2 so i can try to pass the username into the SQL query to bring back only that employees records.


This is the current code for Form 1 below:


Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub SimpleButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SimpleButton1.Click

        Dim login = Me.ELoginTAdapter.UsernamePasswordString(txtusername.Text, txtpassword.Text)
        If Login Is Nothing Then
            txterror.Text = "Incorrect Username or Password"
        Else
            Me.Hide()
            Form2.Show()
        End If
       
End Sub
End Class

Any help is appreciated.

Answers (2)