[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 457
  • Last Modified:

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

Hi,

I need code for username and password in vb.net using database
0
searchsanjaysharma
Asked:
searchsanjaysharma
  • 2
  • 2
1 Solution
 
Luis PérezSoftware Architect in .NetCommented:
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
 
searchsanjaysharmaAuthor Commented:
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
 
Luis PérezSoftware Architect in .NetCommented:
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
 
searchsanjaysharmaAuthor Commented:
ook
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now