hello folks,
let me tell you the plot first.
I am developing a windows application through vb.net,i have done the database connectivity through ms access, which has only two columns, i.e firstname and lastname.
what i want is to maintain a session id so when i browse through all the forms the application knows both the names of the user.

please suggest me the ways to do this as i am new to vb.net.
thanks in advance.
regards
aditya

A simple way is to Use a log in form to ask for them ( a 2 textbox form and an accept and cancel buttons may be enough)
If the user cancels, then close the application.

You can verify if this is an allowed user by searching it in the database of allowed users.

If the user is allowed, then register the start of the session in a public variable in the main module of your application, to be used across all your forms.

Hope this helps

hey lolafuertes,
many thanks for replying.
actually as i have mentioned earlier that i am new to vb.net,can you please present your suggestion with some coding examples.
and also in this application the user is asked once to enter his name and then his marks are fed into the database after the redirection of 5 forms.

Assume you already have a main form in the project called frmMain that is the current startup object.
Add a new form to your project called frmLogin
In this form add a label "First name" and a text box textBoxFirstName.
Then add a label "Last name" and a text box textBoxLastName.
Add a button btnAccept and a button btnCancel
Define the btnAccept as the default button of the form (in the properties of the form)
Also define the btnCancel as the canccel button of the form
Then, on the properties of the buttons click on the event Click to capture it.

On the btnAccept_Click event add

If textBoxFirstName.Text.Trim.Length = 0 or textBoxLastName.Text.Trim.Length = 0 then
    MsgBox "Fill both"
    Exit Sub
End If
CurrentUserFirstName = textBoxFirstName.Text.Trim
CurrentUserLastName = textBoxLastName.Text.Trim
DialogResult=System.Windows.Forms.DialogResult.Yes
Hide

On the btnCancel_Click event add

DialogResult=Systtem.Windows.Forms.DialogResult.No
Hide

Just Create a New Module in your project
In this module add the following:

Public CurrentUserFirstName as string
Public CurrentUserLastName as String

Then add the following

Sub Main
    Dim F as new frmLogin
    Dim result as System.Windows.Forms.DialogResult = F.Showdialog()
    F.Close
    If result = System.Windows.Forms.DialogResult.No Then Exit Sub
    Dim mainFrm as new frmMain
    mainFrm.ShowDialog()
End Sub

On your project properties, change the startup object to be Sub Main.

Test the results

Hope this helps

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.