Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6935289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:04:58+00:00 2026-05-27T12:04:58+00:00

I’m making a login form in VB.NET, and I have a table in mysql

  • 0

I’m making a login form in VB.NET, and I have a table in mysql called user. What I want to do is before a user can login the Administrator column of the user table must be TRUE and the DELETED column must be FALSE. I’ve tried everything I know but all non admin users are still able to login…

Heres how the user table looks like:

+---------------+------------+---------+--------+---------+----------+---------------+---------+
| User_BannerID | FirstName | LastName | Email | Username | Password | Administrator | Deleted |
+---------------+------------+---------+--------+---------+----------+---------------+---------+
|               |            |         |        |         |          |               |         |
|               |            |         |        |         |          |               |         |
+---------------+------------+---------+--------+---------+----------+---------------+---------+

here’s the code:

Imports MySql.Data.MySqlClient
Public Class frmAdlogin

    Private Sub cmdCancel_Click(sender As System.Object, e As System.EventArgs) Handles cmdCancel.Click
        Application.Exit()
    End Sub

    Private Sub cmdLogin_Click(sender As System.Object, e As System.EventArgs) Handles cmdLogin.Click
        Dim conn As New MySqlConnection
        Dim myCommand As New MySqlCommand

        Dim myConnString As String
        Dim UserID As String

        myConnString = "server=" & txtServer.Text & ";" _
  & "user id=" & txtUsername.Text & ";" _
  & "password=" & txtPassword.Text & ";" _
  & "database=attendance"

        conn.ConnectionString = myConnString

        Try
            conn.Open()

            myCommand.Connection = conn
            myCommand.CommandText = "SELECT user_bannerid FROM user WHERE BINARY username = ?Username and administrator = 'TRUE' and deleted = 'FALSE' "
            myCommand.Parameters.Add("?Username", txtUsername.Text)

            UserID = myCommand.ExecuteScalar

            conn.Close()

            Dim AdminForm As New frmAdmin
            AdminForm.UserID = UserID
            AdminForm.connectionString = myConnString
           AdminForm.Show()

            Me.Hide()
            Me.Close()
        Catch myerror As MySqlException
            MessageBox.Show("Invalid login. Please Enter The Correct Server Address And Your Username Plus The Correct Password ")
            conn.Dispose()
        End Try
    End Sub
    Private Sub frmAdlogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.AcceptButton = cmdLogin
        Me.CancelButton = cmdCancel
        txtPassword.PasswordChar = "*"
    End Sub
End Class

EDIT BizApps heres how it looks now:

Imports MySql.Data.MySqlClient
Public Class frmAdlogin

    Private Sub cmdCancel_Click(sender As System.Object, e As System.EventArgs) Handles cmdCancel.Click
        Application.Exit()
    End Sub

    Private Sub cmdLogin_Click(sender As System.Object, e As System.EventArgs) Handles cmdLogin.Click
        Dim conn As New MySqlConnection
        Dim myCommand As New MySqlCommand

        Dim myConnString As String
        Dim UserID As String

        myConnString = "server=" & txtServer.Text & ";" _
  & "user id=" & txtUsername.Text & ";" _
  & "password=" & txtPassword.Text & ";" _
  & "database=attendance"

        conn.ConnectionString = myConnString


        conn.Open()

        myCommand.Connection = conn
        myCommand.CommandText = "SELECT user_bannerid FROM user WHERE BINARY username = ?Username and administrator = 'TRUE' and deleted = 'FALSE' "
        myCommand.Parameters.Add("?Username", txtUsername.Text)
        Dim dt = New DataTable()
        Dim ds = New MySqlDataAdapter(myCommand)

        ds.Fill(dt)

        If (dt.Rows.Count > 0) Then

            conn.Close()

            Dim AdminForm As New frmAdmin
            AdminForm.UserID = UserID
            AdminForm.connectionString = myConnString
            AdminForm.Show()

            Me.Hide()
            Me.Close()
        Else
            MessageBox.Show("Invalid login. Please Enter The Correct Server Address And Your Username Plus The Correct Password ")
        End If

    End Sub
    Private Sub frmAdlogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.AcceptButton = cmdLogin
        Me.CancelButton = cmdCancel
        txtPassword.PasswordChar = "*"
    End Sub
End Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:04:58+00:00Added an answer on May 27, 2026 at 12:04 pm

    First try your query if its working.

     SELECT user_bannerid FROM user WHERE BINARY username ='myusername' and administrator = 'TRUE' and deleted = 'FALSE'
    

    Then if it returns records

    Try this:

     myCommand.Connection = conn
            myCommand.CommandText = "SELECT user_bannerid FROM user WHERE BINARY username = ?Username and administrator = 'TRUE' and deleted = 'FALSE' "
            myCommand.Parameters.Add("?Username", txtUsername.Text)
            Dim dt = new DataTable()
            Dim ds =  New MySqlDataAdapter(myCommand)
    
           ds.Fill(dt)
    
           if(dt.Rows.Count < 1 ) then   // no record found
    
    MessageBox.Show("Invalid login. Please Enter The Correct Server Address And Your Username Plus The Correct Password ")
    
           Else       //record found
    
           conn.Close()
    
            Dim AdminForm As New frmAdmin
            AdminForm.UserID = UserID
            AdminForm.connectionString = myConnString
           AdminForm.Show()
    
            Me.Hide()
            Me.Close()
    
           End If
    

    Regards

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I have a text area in my form which accepts all possible characters from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.