Member Avatar for LobeRoni

Hi, I am new to this place and found this by searching for a log in system tutorial for a Visual Basic 2008 Express Edition. So far I have been able to put a code to have 3 users on:

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If TextBox1.text = "Joshua" And textbox2.text = "fw5je4ty" Then
            MsgBox("You have successfuly loged in!")
            Form2.Show()
            Me.Hide()
        ElseIf textbox1.text = "Jason" And textbox2.text = "sj9sl4fc" Then
            MsgBox("You have successfuly loged in!")
            Form2.Show()
            Me.Hide()
        ElseIf textbox1.text = "Eric" And textbox2.text = "1337" Then
            MsgBox("You have successfuly loged in!")
            Form2.Show()
            Me.Hide()
        ElseIf TextBox1.Text = "" Or textbox2.text = "" Then
            MsgBox("Please enter Username/Password")
        ElseIf MsgBox("Invalid username/password, browser will now shut down") Then
            Application.Exit()
        End If
    End Sub
End Class

But I do not want to have to re-edit this program every time 1 new user signs up for it, meaning I would appreciate any and all help on what to use as a SQL Username/Password database and how to code it. Do not get me wrong, I do not want ALL the coding, I want some serious help, anyone that is will to msn me or skype with me to help me build this.

LobeRoni

Member Avatar for iamthwee

That's a massive request.

I'd look at some basic tutorial about using vb.net and sql/access.

The video ones are quite good.

Another alternative would be to use just a text file. That would overcome you needing to recompile your code every time you add a new user.

Member Avatar for LobeRoni

That's a massive request.

I'd look at some basic tutorial about using vb.net and sql/access.

The video ones are quite good.

Another alternative would be to use just a text file. That would overcome you needing to recompile your code every time you add a new user.

Ok, thanks, the only thing with the text file is that it would have to be online so that everyone gets it updated. That's where I get the problem, I do not know how to make it connect to the internet to check the username and password on anything.

LobeRoni

Can some0ne help .How do i cameup with a login codes using visual basic.net 2008 express edition

Hi,

Here's an example how to create a Login form with a database:

Imports System.Data.OleDb   
  
Public Class LoginForm1   
  
    ' OK button   
    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click   
        Dim con As New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=E:\VBproject\myDB.mdb")   
        Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM Users WHERE userid = '" & usernametextbox.Text & "' AND password = '" & passwordtextbox.Text & "' ", con)   
        con.Open()   
        Dim sdr As OleDbDataReader = cmd.ExecuteReader()   
        ' If the record can be queried, Pass verification and open another form.   
        If (sdr.Read() = True) Then  
            MessageBox.Show("The user is valid!")   
            Dim mainForm As New MainForm   
            mainForm.Show()   
            Me.Hide()   
        Else  
            MessageBox.Show("Invalid username or password!")   
        End If  
    End Sub  
  
    ' Cancel button   
    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click   
        Me.Close()   
   End Sub  
  
End Class

Hey Luc001
Thanks this code you posted helped me out a great deal
was working on it for a while and just two lines of your
code opened my eyes.

Thanks again.

thx for the code ! what kind of database did you use ?

Hi,

As you can read in the code example I gave you find this:

Dim con As New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=E:\VBproject\myDB.mdb")

And that says I've used a Access database. ( myDB.mdb )

Hi, Luc001!

I had tried with your codes, it works well. Thank you very much! Here, i need more codes over the database connection issues like successful record updates after the connection is get closed, report generations and all with error handlings.

Hi,

This thread is already 2 years old.
Please start another one and we'll glad to help you with your problem.
Thanks in advance.

Hi,
thanks for your reply.
i know this is a two years old thread but i need that codes for my project works. so please help meme.

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.