Solved

How to check username and password/Login code in Vb.net

Posted on 2012-03-20
4
426 Views
Last Modified: 2012-03-26
Hi,

I need code for username and password in vb.net using database
0
Comment
Question by:searchsanjaysharma
  • 2
  • 2
4 Comments
 
LVL 25

Expert Comment

by:Luis Pérez
ID: 37741697
Sometimes it's incredible how you write your questions. We're experts, but not magicians. With the information you supplied it's impossible than any of us can give you a good code... Please, re-write your question providing the information that we need... what database (sql server, oracle, access, mysql...)? what running platform (windows forms, web forms, mvc...)? what version of .net framework? Is the password encrypted in any way? Is is possible that you provide your USERS table name and fields?
0
 

Author Comment

by:searchsanjaysharma
ID: 37741715
When i am descriptive then i get most of the general answers, and there are few experts only who actually reach out to help to solve the problem.

Anyways,
DB Server: Sqlserver
Database : dbac
Table:mstusers
Fields:username and password
Vb.Net 2008.


D
0
 
LVL 25

Accepted Solution

by:
Luis Pérez earned 500 total points
ID: 37741775
Try this:

    Public Function CheckLogin(ByVal username As String, ByVal password As String) As Boolean
        Dim output As Boolean

        Using connection As SqlConnection = New SqlConnection("your_connection_string")
            connection.Open()

            Using cmd As SqlCommand = New SqlCommand("SELECT COUNT(*) FROM mstusers WHERE username = '" + username + "' AND password = '" + password + "'", connection)
                Dim ret As Integer = cmd.ExecuteScalar()
                output = ret.Equals(1)
            End Using
        End Using

        Return output
    End Function

Open in new window


Hope that helps.
0
 

Author Closing Comment

by:searchsanjaysharma
ID: 37767308
ook
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now