VB.NET - How To Create Login Form With SQL Server DataBase With Source Code
In This VB.NET Tutorial We Will See How To Make Login Window With Microsoft SQL DataBase And Visual Basic .NET Programming Language.
Project Source Code:
Imports System.Data.SqlClient
Public Class VBNET_Login_Form_With_SQL
Private Sub BTN_LOGIN_Click(sender As Object, e As EventArgs) Handles BTN_LOGIN.Click
Dim connection As New SqlConnection("Server= SAMSNG-PC; Database = TestDB; Integrated Security = true")
Dim command As New SqlCommand("select * from Table_Login where Username = @username and Password = @password", connection)
command.Parameters.Add("@username", SqlDbType.VarChar).Value = TextBoxUsername.Text
command.Parameters.Add("@password", SqlDbType.VarChar).Value = TextBoxPassword.Text
Dim adapter As New SqlDataAdapter(command)
Dim table As New DataTable()
adapter.Fill(table)
If table.Rows.Count() <= 0 Then
MessageBox.Show("Username Or Password Are Invalid")
Else
'MessageBox.Show("Login Successfully")
Dim frm As New VBNET_SQL_Insert_Update_Delete()
Me.Hide()
frm.Show()
End If
End Sub
Private Sub BTN_CANCEL_Click(sender As Object, e As EventArgs) Handles BTN_CANCEL.Click
Me.Close()
End Sub
End Class
///////////////OUTPUT:
Download Projects Source Code
2 comments
commentsHow do i make it in a way i retrieve information for example i click name button it will give me a name from database and if i keep clicking name it will be generating all names in database in the textbox
ReplyWhere do I create the SQL database for this code?
Reply