Hi All,

I have a log in form, I have had a couple of idea's.

When a user logs in I want his/her name to print on the top of the main form with the current date, the data for the login form is collected from a sql database (not sure if that is relevant).

also, I have a particular button on the main form I only want active when the Administrator logs in, if anyone else logs in I want the button inactive.

Can anyone give me some idea's on how to achieve the above.

Thanks very much

John

i dont know how you have this setup, but i can give you an example of how i do

i have a sql database with a system users table. contains the following:
id, name, username, password, securityid, email

whenever the user logs in, check database for who it is
save the name into the applications settings (my.settings.username?)
save the securityid into the applications settings (my.settings.security?)

mainform.text = my.settings.username & " " & formatdatetime(now(), dateformat.longdate)

then on your mainform.load

select case my.settings.security
case is admin
me.btn.show
case else
me.btn.hide
end select


there is one simple way you can do it

you know how you say, save to my settings, how do I do that through code, your database is very similar to my database and your right, this looks to be the easiest way.

this is the code for my login form

Imports System.Data.SqlClient
Public Class Form2

    Dim conn As SqlConnection
    Dim Users As SqlDataAdapter
    Dim dsUsers As DataSet

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Users.Update(dsUsers, "Users")
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        conn = New SqlConnection("Data Source=JOHN-ELLIS-PC;Initial Catalog=Usersdb;Integrated Security=True")
        dsUsers = New DataSet
        Users = New SqlDataAdapter("SELECT UserID,Name,Password,Phone FROM Users", conn)
        Dim cmdBldr As SqlCommandBuilder = New SqlCommandBuilder(Users)
        Users.Fill(dsUsers, "Users")
        DataGridView1.DataSource = dsUsers.Tables("Users")

    End Sub
End Class

thanks

john

my.settings.username = "whatever"

you have to create them

project - properties - settings

This article has been dead for over six months. Start a new discussion instead.