How to create a login in VB.NET
how to create a login in vb.net
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted May 16, 2012, 5:37 AM
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