How to create a login in VB.NET
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted May 16, 2012, 1:37 AM EDT
Try this...
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim ConnectionString As String = System.Configuration.ConfigurationSettings.AppSettings("dsn")
Dim com As OleDbCommand
Dim str As String
Dim obj As Object = Nothing
Private Sub btn_login_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_login.Click
Dim con As New OleDbConnection(ConnectionString)
con.Open()
str = "select count(*) from login where UserName=@UserName and Password =@Password"
com = New OleDbCommand(str, con)
com.CommandType = CommandType.Text
com.Parameters.AddWithValue("@UserName", TextBox_user_name.Text)
com.Parameters.AddWithValue("@Password", TextBox_password.Text)
obj = com.ExecuteScalar()
If CInt(obj) <> 0 Then
lb1.Text = "WELLCOME :: " + TextBox_user_name.Text
Else
lb1.Text = "invalid user name and password"
End If
con.Close()
End Sub
End Class
Thanks