VB.NET Login & Registration Form with SQL Server + Source Code

VB.NET for beginner : how to create Simple application user Registration Form with SQL Server Databse? download full Source Code student login & Registration MD5 Password + SQL Server

VB.NET for beginner - How to create student registration and login form vb net using SQL server with MD5 password? today i'll show you ho to make simple application for registration and login form vb.net programming language and you can use for registration student. Tutorial sebelumnya kami sudah membahas tentang cara sederhana membuat form login untuk guru atau siswa dengan MD5 Password juga dengan memiliki level access yang berbeda.

Baca : Source Code Login Form dengan SQL server
Login Form MD5 Password dengan MySQL Database

Hari ini kita akan mencoba membuat aplikasi sederhana login user juga namun dengan menambahkan form untuk registrasi user, login dan registrasi ini memiliki akses level yang berbeda dan bisa di sesuaikan saat di form pendaftaran. langsung saja kita coding ya.

1. Membuat Database SQL Server

Buatlah sebuah database di SQL server dengan nama "Login_db" atau bisa disesuaikan dengan kebutuhan. dan buat table baru dengan nama "user" dan field nya terdiri dari "id_user,email,password,level". atau kamu bisa mengeksekusi perintah berikut :
CREATE TABLE [dbo].[users](
 [id_user] [int] IDENTITY(1,1) NOT NULL,
 [email] [varchar](255) NOT NULL,
 [password] [varchar](255) NULL,
 [level] [varchar](255) NULL,
PRIMARY KEY CLUSTERED 
(
 [id_user] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
Kamu bisa menyesuaikan sesuai kebutuhan saja.

2. Membuat Project Baru dan Form Login


Buatlah project baru di Visual studio 2015 dan pada Form1.vb rename menjadi "FrmLogin.vb" serta desain tampilan FrmLogin.vb menjadi seperti tampilan dibawah ini :

VB.NET Login form sql server

3. Membuat Form Sign Up

Buatlah Form baru dengan nama "FrmSignUp.vb" serta desain tampilan seperti dibawah ini :

vb.net Registration Form with SQL Server

4. Membuat Module Connection (SQL Server)

Untuk membuat koneksi ke database SQL Server, mari kita membuat module baru dan beri nama "ModuleConnection.vb" dan tuliskan seluruh code dibawah ini :
Imports System.Data.SqlClient
Module ModuleConnection
    Public connection As SqlConnection ' declaration our connection
    ' function fo connection
    Sub OpenConnection()
        Try
            ' function for connection
            ' Before create a connection, you must have a database (Sql Server)
            ' i was create a database in my SQL Server,
            ' so just create a database and a user table.
            ' in user table create field id_user(Use auto increment)
            ' email and level. lets see my database
            connection = New SqlConnection("Data Source=DESKTOP-5VBP3C9\SQLEXPRESS;Initial Catalog=crud_sqlserver;Integrated Security=True")
            If connection.State = ConnectionState.Closed Then
                connection.Open() ' open the connection
            End If
        Catch ex As Exception
            ' if failed
            MsgBox("Failed to connect, Error at " & ex.ToString)
        End Try
    End Sub
End Module

Sesuaikan dengan server yang kamu gunakan.

5. Source Code Form Login (FrmLogin.vb)

Imports System.Data.SqlClient ' import namespace
Public Class FrmLogin
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        OpenConnection() ' open our connection
        Dim dr As SqlDataReader
        Dim cmd As SqlCommand
        Dim sql As String
        cmd = New SqlCommand
        cmd.CommandType = CommandType.Text
        cmd.Connection = connection ' our connection
        sql = "select * from users where email='" & TextBox1.Text & "' and password=CONVERT(NVARCHAR(32),HashBytes('MD5','" & TextBox2.Text & "'),2)"
        ' the query above will read a MD5 password format.
        ' im soryy
        cmd.CommandText = sql
        dr = cmd.ExecuteReader()
        If dr.HasRows Then
            dr.Read() ' read all data from database
            If dr.Item("level") = 1 Then
                ' show new form for our Administrators
                ' but i just show the message for administrator account
                MsgBox("Welcome Administrator")
            ElseIf dr.Item("level") = 2
                ' its for user account
                MsgBox("Wellcome User")
            ElseIf dr.Item("level") = 3
                ' its for another level access
                MsgBox("Wellcome Other")
            End If
        Else ' if dataread not same with username or password inthe textbox
            MsgBox("Access denied")
        End If
        connection.Close() ' close connection
        cmd.Dispose()
    End Sub
    Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        ' show the registrations form
        FRMsignup.Show()
    End Sub
End Class

6. Source Code Form Registration (FrmSignUp.vb)

Imports System.Data.SqlClient ' import namespace
Public Class FRMsignup
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim TypeUser As String
        Dim Level As Integer

        TypeUser = ComboBox1.Text
        If TypeUser = "Administrator" Then
            Level = 1
        ElseIf TypeUser = "User"
            Level = 2
        ElseIf TypeUser = "Other"
            Level = 3
            ' create other level access here
        End If

        Dim sql As String = "insert into users(email,password,level)values('" & TextBox1.Text & "',CONVERT(NVARCHAR(32),HashBytes('MD5','" & TextBox2.Text & "'),2)," & Level & ")"
        ' SHITT, I FORGED IT
        ' execute to database
        SignUp(sql)
        MsgBox("Sign Up Success !") ' show message

    End Sub
    ' create function for register
    Private Sub SignUp(ByVal sql As String)
        Dim cmd As New SqlCommand
        OpenConnection() ' open our connection
        Try
            cmd.Connection = connection ' our connection
            cmd.CommandType = CommandType.Text
            cmd.CommandText = sql
            cmd.ExecuteNonQuery()
            cmd.Dispose()
            connection.Close() ' close our connection
        Catch ex As Exception
            MsgBox("Failed " & ex.ToString) ' if failed
        End Try
    End Sub
    Private Sub FRMsignup_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        ComboBox1.Text = "Administrator"
    End Sub
End Class

Jika tutorial Cara Membuat Login & Registration Form with SQL Server diatas masih kurang jelas, silahkan lihat video tutorialnya berikut ini :

Video tutorial Login & Registration Form with SQL Server


Download Database Project Form SignUp & Login SQL Server
Download Source Code Project Form SignUp & Login SQL Server

Jangan lupa share dan subscribe jika bermanfaat. terima kasih.

COMMENTS

Next Recomended


Feel free to code it up and send us a pull request.

Hi everyone, let's me know how much this lesson can help your work. Please Subscribe and Follow Our Social Media 'kodeajaib[dot]com' to get Latest tutorials and will be send to your email everyday for free!, Just hit a comment if you have confused. Nice to meet you and Happy coding :) all ^^



Follow by E-Mail


Name

ADO.NET,3,Ajax,6,Android,9,AngularJS,4,ASP.NET,4,Blogger Tutorials,7,Bootstrap,7,C++,1,Codeigniter,2,Cplusplus,6,Crystal Report,6,CSharp,25,Ebook Java,2,FlyExam,1,FSharp,3,Game Development,2,Java,35,JDBC,2,Laravel,84,Lumen,2,MariaDB,2,Ms Access,3,MySQL,31,ODBC,6,OleDB,1,PHP,14,PHP Framework,5,PHP MYSQLI,9,PHP OOP,5,Python,8,Python 3,4,SQL Server,4,SQLite,4,Uncategorized,5,Vb 6,2,Vb.Net,89,Video,48,Vue Js,4,WPF,2,Yii,3,
ltr
item
KODE AJAIB: VB.NET Login & Registration Form with SQL Server + Source Code
VB.NET Login & Registration Form with SQL Server + Source Code
VB.NET for beginner : how to create Simple application user Registration Form with SQL Server Databse? download full Source Code student login & Registration MD5 Password + SQL Server
https://4.bp.blogspot.com/-cILc14Mx9i4/V0OcAWhRxMI/AAAAAAAABxI/OcV5uS8jPRgkCfDVjm-aeh2Ye9LWqfAxgCLcB/s320/login-form-vbnet.jpg
https://4.bp.blogspot.com/-cILc14Mx9i4/V0OcAWhRxMI/AAAAAAAABxI/OcV5uS8jPRgkCfDVjm-aeh2Ye9LWqfAxgCLcB/s72-c/login-form-vbnet.jpg
KODE AJAIB
https://www.kodeajaib.com/2016/05/vbnet-login-registration-form-with-sql-server.html
https://www.kodeajaib.com/
https://www.kodeajaib.com/
https://www.kodeajaib.com/2016/05/vbnet-login-registration-form-with-sql-server.html
true
3214704946184383982
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy