Solved

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

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

I need code for username and password in vb.net using database
0
Comment
Question by:searchsanjaysharma
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 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