Solved

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

Posted on 2012-03-20
4
424 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
ook
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

10 Experts available now in Live!

Get 1:1 Help Now