Membuat Form Login VB.NET Database SQL Server 2008

5

Membuat Form Login VB.NET Database SQL Server 2008, setelah sebelumnya saya posting koneksi VB.NET dengan Database SQL Server 2008, maka kali ini saya akan share membuat login vb.Net dengan database SQL Server 2008.langsung saja…

  1. Pastikan teman-teman telah membuat database login di SQL Server, Misal:
    0
  2. Buat project pada visual studio. design suka-suka lah, misal ky gini bro..!
    2
    Keterangan:
    button: text: &login, name:login
    button1:text:&batal, name:button1sekalian buat menu utama;
    4
    Keterangan:
    Name; menuutama
  3. Kemudian add module, misal namanya module1;
    Masukan Script berikut;

    Imports System.Data.SqlClient
    Module Module1
    Public conn As SqlConnection
    Public cmd As SqlCommand
    Public ds As DataSet
    Public adapter As SqlDataAdapter
    Public rd As SqlDataReader
    Public lokasidb As String
    Dim x As StringPublic Sub ambilkoneksi()
    lokasidb = "Data Source=DWI\SQLEXPRESS;Initial Catalog=NET;Persist Security Info=True;User ID=sa; password=12345"
    conn = New SqlConnection(lokasidb)
    Try
    If conn.State = ConnectionState.Closed Then
    conn.Open()
    End If
    Catch ex As Exception
    MsgBox(Err.Description, MsgBoxStyle.Critical, "Error")
    End Try
    End Sub
    End Module

    1

  4. Kemudian double click button login dan masukan script berikut;
    Imports System.Data.SqlClient
    Public Class Form1Private Sub Login_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Login.Click
    ambilkoneksi()
    cmd = New SqlCommand("select * from login where user_name='" & TextBox1.Text & "' and password='" & TextBox2.Text & "'", conn)
    rd = cmd.ExecuteReader
    rd.Read()
    If rd.HasRows Then
    menuutama.Show()
    Me.Hide()
    Else
    MsgBox("login salah, periksa kembali user name dan password")
    TextBox1.Focus()
    End If
    TextBox1.Text = " "
    TextBox2.Text = " "
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.TextBox1.Focus()
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Me.Close()
    End Sub
    End Class

    3

  5. Terus Running (F5)
    5
    jika Nama atau Password salah
    6
    Jika Nama dan Password benar maka akan muncul menu utama.
    7
    Sekian dan terima kasih……..

sumber : silowoakai

Cara Daftar Google Adsense Indonesia Agar Cepat Diterima

Google Adsense adalah salah satu program PPC (Pay Per Click) yang paling banyak digemari oleh ...

Learn more
Share This:Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPin on Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *