none
Vikal RRS feed

  • Question

  • please check my code

    Option Explicit On
    Imports System.Data.OleDb

    Public Class LOGIN
        Dim objcon As New OleDbConnection
        Dim strSql As String
        Dim strconnection As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\HRMS\HRMS\Database1.accdb"
        Dim da As New OleDb.OleDbDataAdapter
        Dim ds As New DataSet
        Dim Attempt As Integer = 0

        Private Sub BTN_LOG_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTN_LOG.Click
            Dim warning As String = "warning!" & vbNewLine & vbNewLine + _
            "if Attempt var = 3" + vbNewLine + _
            "system will shut down,"

            If (TXT_US.Text = "") And (TXT_P.Text = "") Then
                Attempt = Attempt + 1
                MsgBox("please input user name and password!" & vbNewLine & vbNewLine + _
                warning, MsgBoxStyle.Exclamation, " sorry sir!" & _
                "now Attempt var= " & Attempt)

            ElseIf (TXT_US.Text = "") Then
                Attempt = Attempt + 1
                MsgBox("please input user name!" & vbNewLine & vbNewLine + _
                warning, MsgBoxStyle.Information, " sorry sir!" & _
                "now Attempt var= " & Attempt)
            ElseIf (TXT_P.Text = "") Then
                Attempt = Attempt + 1
                MsgBox("please input password!" & vbNewLine & vbNewLine + _
                warning, MsgBoxStyle.Information, " sorry sir!" & _
                "now Attempt var= " & Attempt)

            Else
                Dim strName = TXT_US.Text
                Dim strPass = TXT_P.Text

                With objcon
                    .Close()
                    If .State = ConnectionState.Closed Then
                        .ConnectionString = strconnection
                        .Open()
                        MsgBox("connectionsStat.open", MsgBoxStyle.Information, "Connected")
                    End If

                End With

                ds.Clear()
                strSql = " Select * from TB_LOG Where Name ='" & TXT_US.Text & "' & And  Pass ='" & TXT_P.Text & "'"

                da = New OleDbDataAdapter(strSql, objcon)
                da.Fill(ds, "TB_LOG")
                If ds.Tables("TB_Log").Rows.Count <> 0 Then
                    MaximizeBox = True
                    MinimizeBox = True
                    MsgBox("Hello!" + strName + vbNewLine + _
                    "Log in successfully", MsgBoxStyle.OkOnly, _
                    "Welcome " + strName)
                Else

                    MaximizeBox = False
                    MinimizeBox = False

                    Attempt = Attempt + _
                    MsgBox("OOP!-->" & strPass + vbNewLine + vbNewLine + _
                            " The user name or password you entred" + vbNewLine + _
                            " IS Not Valid," + vbNewLine + _
                            "Please Try again", MsgBoxStyle.Exclamation, "invalid")
                End If

            End If
            If Attempt = 3 Then
                MsgBox("window is shuting down....", MsgBoxStyle.Critical, "good bye sir")
                Me.Close()

            End If
        End Sub
    End Class

    • Edited by Vikalsatya Tuesday, February 19, 2019 10:37 AM
    Tuesday, February 19, 2019 10:35 AM

All replies

  • problem in run

    Tuesday, February 19, 2019 10:37 AM
  • Hello,

    This

    strSql = " Select * from TB_LOG Where Name ='" & TXT_US.Text &
             "' & And  Pass ='" & TXT_P.Text & "'"
    

    Should be

    strSql = " Select * from TB_LOG Where Name ='" & TXT_US.Text &
         "' And  Pass ='" & TXT_P.Text & "'"
    


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Proposed as answer by Alex Li-MSFT Wednesday, February 20, 2019 7:11 AM
    Tuesday, February 19, 2019 11:16 AM
    Moderator
  • Hi Vikalsatya,

    Do you resolve the issue? If you resolve the issue, please mark the helpful as answer. 

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, February 22, 2019 8:38 AM