Solved

Search button

Posted on 2016-09-23
7
30 Views
Last Modified: 2016-10-26
This is my code can you help me with the code for the search button

Public Class frmTrainer

    Dim Mode As String
    Dim path As String = " Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\mandlak\Desktop\Swazi Nkosi\CPISAT9910280197089.accdb"

    Private Function GetNextTrainerNo()
        Dim TrainerNo As Integer


        Try
            Dim connection As New OleDb.OleDbConnection
            Dim command As New OleDb.OleDbCommand
            Dim table As New Data.DataTable


            connection.ConnectionString = path
            connection.Open()


            command.Connection = connection
            command.CommandText = "SELECT TOP 1 Trainer_No FROM Trainer ORDER BY Trainer_No DESC"


            table.Load(command.ExecuteReader())
            connection.Close()

            If table.Rows.Count > 0 Then
                If Integer.TryParse(table(0)("Trainer_No").ToString(), TrainerNo) Then

                    TrainerNo = TrainerNo + 1

                End If
            Else
                TrainerNo = 221
            End If

        Catch ex As Exception
            MessageBox.Show(ex.ToString)

        End Try

        Return TrainerNo

    End Function
    Private Function GetScaleID()
        Dim ScaleID As Integer


        Try
            Dim connection As New OleDb.OleDbConnection
            Dim command As New OleDb.OleDbCommand
            Dim table As New Data.DataTable


            connection.ConnectionString = path
            connection.Open()


            command.Connection = connection
            command.CommandText = "SELECT TOP 1 Scale_ID FROM Trainer ORDER BY Trainer_No DESC"


            table.Load(command.ExecuteReader())
            connection.Close()

            If table.Rows.Count > 0 Then
                If Integer.TryParse(table(0)("Scale_ID").ToString(), ScaleID) Then



                End If
            End If

        Catch ex As Exception
            MessageBox.Show(ex.ToString)

        End Try

        Return ScaleID

    End Function

    Private Function GetMonthlySalary()

        Dim MonthlySalary As Integer


        Try
            Dim connection As New OleDb.OleDbConnection
            Dim command As New OleDb.OleDbCommand
            Dim table As New Data.DataTable


            connection.ConnectionString = path
            connection.Open()


            command.Connection = connection
            command.CommandText = "SELECT Monthly_Salary FROM Trainer ORDER BY Trainer_ID DESC"


            table.Load(command.ExecuteReader())
            connection.Close()

            If table.Rows.Count > 0 Then
                If Integer.TryParse(table(0)("Monthly_Salary").ToString(), MonthlySalary) Then


                End If
            End If

        Catch ex As Exception
            MessageBox.Show(ex.ToString)

        End Try

        Return MonthlySalary

    End Function

    Private Sub GetTrainers()
        txtID.Text = ""
        txtName.Text = ""
        txtSurnamr.Text = ""
        txtContactNo.Text = ""
        txtClassType.Text = ""
        txtmonthlysalary.Text = ""
        txtScaleID.Text = ""
        txtTrainerNo.Text = ""

        Try
            Dim connection As New OleDb.OleDbConnection
            Dim command As New OleDb.OleDbCommand
            Dim table As New Data.DataTable


            connection.ConnectionString = path
            connection.Open()


            command.Connection = connection
            command.CommandText = "SELECT* FROM Trainer ORDER BY Trainer_No"

            table.Load(command.ExecuteReader())
            connection.Close()

            grvTrainer.DataSource = table

        Catch ex As Exception
            MessageBox.Show(ex.ToString)

        End Try

    End Sub

    Private Sub GetTrainer(ByVal pID As Integer)

        Try
            Dim connection As New OleDb.OleDbConnection
            Dim command As New OleDb.OleDbCommand
            Dim table As New Data.DataTable


            connection.ConnectionString = path
            connection.Open()


            command.Connection = connection
            command.CommandText = "SELECT* FROM Trainer WHERE ID=@ID"

            Dim parID = New OleDb.OleDbParameter("@ID", pID)
            command.Parameters.Add(parID)

            table.Load(command.ExecuteReader())
            connection.Close()


            If table.Rows.Count > 0 Then

                txtID.Text = table(0)("ID").ToString
                txtName.Text = table(0)("Trainer_Name").ToString
                txtSurnamr.Text = table(0)("Trainer_Surname").ToString
                txtContactNo.Text = table(0)("Contact_No").ToString
                txtClassType.Text = table(0)("Class_Type").ToString
                txtmonthlysalary.Text = table(0)("Monthly_Salary").ToString
                txtScaleID.Text = table(0)("Scale_ID").ToString
                txtTrainerNo.Text = table(0)("Trainer_No").ToString
            End If

        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try
    End Sub

    Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
        grvTrainer.Enabled = False

        btnAdd.Enabled = False
        btnUpdate.Enabled = False
        btnDelete.Enabled = False

        'Enabling for the Add event
        btnSubmit.Enabled = True
        btnCancel.Enabled = True

        Mode = "INSERT"

        txtID.Text = ""
        txtName.Text = ""
        txtSurnamr.Text = ""
        txtContactNo.Text = ""
        txtClassType.Text = ""


        txtmonthlysalary.Text = GetMonthlySalary().ToString
        txtScaleID.Text = GetScaleID().ToString
        txtTrainerNo.Text = GetNextTrainerNo().ToString()


    End Sub

    Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click
        If grvTrainer.Rows.Count > 0 Then

            If MessageBox.Show("Want to delete?", "Confirm delete?", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

                Try
                    Dim connection As New OleDb.OleDbConnection
                    Dim command As New OleDb.OleDbCommand


                    connection.ConnectionString = path
                    connection.Open()

                    command.Connection = connection
                    command.CommandText = "DELETE FROM Trainer WHERE ID = @ID"


                    Dim parID = New OleDb.OleDbParameter("@ID", grvTrainer.CurrentRow.Cells("ID").Value)
                    command.Parameters.Add(parID)
                    command.ExecuteNonQuery()
                    connection.Close()
                    GetTrainers()

                Catch ex As Exception
                    MessageBox.Show(ex.ToString)
                End Try
            End If
        Else
            MessageBox.Show("There are no records to delete......")
        End If
    End Sub

    Private Sub frmTrainer_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        GetTrainers()
        btnSubmit.Enabled = False
        btnCancel.Enabled = False
        Mode = ""

    End Sub

    Private Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click

        If String.IsNullOrEmpty(txtName.Text) Then
            MessageBox.Show("Please enter a name")
            Return
        End If

        If String.IsNullOrEmpty(txtSurnamr.Text) Then
            MessageBox.Show("Please enter a surname")
            Return
        End If

        If String.IsNullOrEmpty(txtContactNo.Text) Then
            MessageBox.Show("Please enter the contact no")
            Return
        End If

        If String.IsNullOrEmpty(txtClassType.Text) Then
            MessageBox.Show("Please enter the class type")
            Return
        End If

        Select Case Mode

            Case "INSERT"

                Try
                    Dim connection As New OleDb.OleDbConnection
                    Dim command As New OleDb.OleDbCommand

                    connection.ConnectionString = path
                    connection.Open()


                    command.Connection = connection
                    command.CommandText = "INSERT INTO Trainer (Trainer_Name, Trainer_Surname,Contact_No,Class_Type,Monthly_Salary,Scale_ID,Trainer_No)VALUES(@Name, @Surname, @ContactNo, @ClassType, @MonthlySalary,ScaleID, @TrainerNo)"

                    Dim parName = New OleDb.OleDbParameter("@Name", txtName.Text)
                    Dim parSurname = New OleDb.OleDbParameter("@Surname", txtSurnamr.Text)
                    Dim parContactNo = New OleDb.OleDbParameter("@ContactNo", txtContactNo.Text)
                    Dim parClassType = New OleDb.OleDbParameter("@ClassType", txtClassType.Text)
                    Dim parMonthlySalary = New OleDb.OleDbParameter("@MonthlySalary", txtmonthlysalary.Text)
                    Dim parScaleID = New OleDb.OleDbParameter("@ScaleID", txtScaleID.Text)
                    Dim parTrainerNo = New OleDb.OleDbParameter("@TrainerNo", txtTrainerNo.Text)


                    command.Parameters.Add(parName)
                    command.Parameters.Add(parSurname)
                    command.Parameters.Add(parContactNo)
                    command.Parameters.Add(parClassType)
                    command.Parameters.Add(parMonthlySalary)
                    command.Parameters.Add(parScaleID)
                    command.Parameters.Add(parTrainerNo)

                    command.ExecuteNonQuery()
                    connection.Close()
                    GetTrainers()

                Catch ex As Exception
                    MessageBox.Show(ex.ToString)
                End Try



            Case "UPDATE"

                Try
                    Dim connection As New OleDb.OleDbConnection
                    Dim command As New OleDb.OleDbCommand


                    connection.ConnectionString = path
                    connection.Open()

                    command.Connection = connection
                    command.CommandText = "UPDATE Trainer SET Trainer_Name=@Name, Trainer_Surname=@Surname, Contact_No=@ContactNo, Class_Type=@ClassType WHERE ID = @ID"


                    Dim parName = New OleDb.OleDbParameter("@Name", txtName.Text)
                    Dim parSurname = New OleDb.OleDbParameter("@Surname", txtSurnamr.Text)
                    Dim parID = New OleDb.OleDbParameter("@ID", txtID.Text)
                    Dim parContactNo = New OleDb.OleDbParameter("@ContactNo", txtContactNo.Text)
                    Dim parClassType = New OleDb.OleDbParameter("@ClassType", txtClassType.Text)



                    'Adding Parameters to the command object
                    command.Parameters.Add(ParName)
                    command.Parameters.Add(parSurname)
                    command.Parameters.Add(parID)
                    command.Parameters.Add(parContactNo)
                    command.Parameters.Add(parClassType)


                    'Executing Parameters
                    command.ExecuteNonQuery()
                    connection.Close()
                    GetTrainers()

                Catch ex As Exception
                    MessageBox.Show(ex.ToString())

                End Try

            Case Else
                MessageBox.Show("Nothing to Submit")

        End Select

        Mode = ""
        grvTrainer.Enabled = True
        btnSubmit.Enabled = False
        btnCancel.Enabled = False

        btnAdd.Enabled = True
        btnDelete.Enabled = True
        btnUpdate.Enabled = True

    End Sub

    Private Sub grvTrainer_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles grvTrainer.CellContentClick

        Dim ID As Integer

        If Integer.TryParse(grvTrainer.CurrentRow.Cells("ID").Value.ToString(), ID) Then
            GetTrainer(ID)
        End If

    End Sub

    Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click

        grvTrainer.Enabled = True
        btnSubmit.Enabled = False
        btnCancel.Enabled = False

        btnAdd.Enabled = True
        btnDelete.Enabled = True
        btnUpdate.Enabled = True
        Mode = ""

        If grvTrainer.Rows.Count > 0 Then
            Dim ID As Integer

            If Integer.TryParse(grvTrainer.CurrentRow.Cells("ID").Value.ToString(), ID) Then
                GetTrainer(ID)
            End If

            txtID.Text = ""
            txtName.Text = ""
            txtSurnamr.Text = ""
            txtContactNo.Text = ""
            txtClassType.Text = ""
            txtmonthlysalary.Text = ""
            txtScaleID.Text = ""
            txtTrainerNo.Text = ""
        End If

    End Sub

    Private Sub btnUpdate_Click(sender As Object, e As EventArgs) Handles btnUpdate.Click

        btnAdd.Enabled = False
        btnDelete.Enabled = False
        btnUpdate.Enabled = False

        btnSubmit.Enabled = True
        btnCancel.Enabled = True

        Mode = "UPDATE"

    End Sub

    Private Sub BtnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
        Application.Exit()
    End Sub

   
End Class
0
Comment
Question by:Swazi Nkosi
[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
  • 4
  • 3
7 Comments
 
LVL 82

Expert Comment

by:David Johnson, CD, MVP
ID: 41812186
Public Class frmTrainer

    Dim Mode As String
    Dim path As String = " Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\mandlak\Desktop\Swazi Nkosi\CPISAT9910280197089.accdb"

    Private Function GetNextTrainerNo()
        Dim TrainerNo As Integer


        Try
            Dim connection As New OleDb.OleDbConnection
            Dim command As New OleDb.OleDbCommand
            Dim table As New Data.DataTable


            connection.ConnectionString = path
            connection.Open()


            command.Connection = connection
            command.CommandText = "SELECT TOP 1 Trainer_No FROM Trainer ORDER BY Trainer_No DESC"


            table.Load(command.ExecuteReader())
            connection.Close()

            If table.Rows.Count > 0 Then
                If Integer.TryParse(table(0)("Trainer_No").ToString(), TrainerNo) Then

                    TrainerNo = TrainerNo + 1

                End If
            Else
                TrainerNo = 221
            End If

        Catch ex As Exception
            MessageBox.Show(ex.ToString)

        End Try

        Return TrainerNo

    End Function
    Private Function GetScaleID()
        Dim ScaleID As Integer


        Try
            Dim connection As New OleDb.OleDbConnection
            Dim command As New OleDb.OleDbCommand
            Dim table As New Data.DataTable


            connection.ConnectionString = path
            connection.Open()


            command.Connection = connection
            command.CommandText = "SELECT TOP 1 Scale_ID FROM Trainer ORDER BY Trainer_No DESC"


            table.Load(command.ExecuteReader())
            connection.Close()

            If table.Rows.Count > 0 Then
                If Integer.TryParse(table(0)("Scale_ID").ToString(), ScaleID) Then



                End If
            End If

        Catch ex As Exception
            MessageBox.Show(ex.ToString)

        End Try

        Return ScaleID

    End Function

    Private Function GetMonthlySalary()

        Dim MonthlySalary As Integer


        Try
            Dim connection As New OleDb.OleDbConnection
            Dim command As New OleDb.OleDbCommand
            Dim table As New Data.DataTable


            connection.ConnectionString = path
            connection.Open()


            command.Connection = connection
            command.CommandText = "SELECT Monthly_Salary FROM Trainer ORDER BY Trainer_ID DESC"


            table.Load(command.ExecuteReader())
            connection.Close()

            If table.Rows.Count > 0 Then
                If Integer.TryParse(table(0)("Monthly_Salary").ToString(), MonthlySalary) Then


                End If
            End If

        Catch ex As Exception
            MessageBox.Show(ex.ToString)

        End Try

        Return MonthlySalary

    End Function

    Private Sub GetTrainers()
        txtID.Text = ""
        txtName.Text = ""
        txtSurnamr.Text = ""
        txtContactNo.Text = ""
        txtClassType.Text = ""
        txtmonthlysalary.Text = ""
        txtScaleID.Text = ""
        txtTrainerNo.Text = ""

        Try
            Dim connection As New OleDb.OleDbConnection
            Dim command As New OleDb.OleDbCommand
            Dim table As New Data.DataTable


            connection.ConnectionString = path
            connection.Open()


            command.Connection = connection
            command.CommandText = "SELECT* FROM Trainer ORDER BY Trainer_No"

            table.Load(command.ExecuteReader())
            connection.Close()

            grvTrainer.DataSource = table

        Catch ex As Exception
            MessageBox.Show(ex.ToString)

        End Try

    End Sub

    Private Sub GetTrainer(ByVal pID As Integer)

        Try
            Dim connection As New OleDb.OleDbConnection
            Dim command As New OleDb.OleDbCommand
            Dim table As New Data.DataTable


            connection.ConnectionString = path
            connection.Open()


            command.Connection = connection
            command.CommandText = "SELECT* FROM Trainer WHERE ID=@ID"

            Dim parID = New OleDb.OleDbParameter("@ID", pID)
            command.Parameters.Add(parID)

            table.Load(command.ExecuteReader())
            connection.Close()


            If table.Rows.Count > 0 Then

                txtID.Text = table(0)("ID").ToString
                txtName.Text = table(0)("Trainer_Name").ToString
                txtSurnamr.Text = table(0)("Trainer_Surname").ToString
                txtContactNo.Text = table(0)("Contact_No").ToString
                txtClassType.Text = table(0)("Class_Type").ToString
                txtmonthlysalary.Text = table(0)("Monthly_Salary").ToString
                txtScaleID.Text = table(0)("Scale_ID").ToString
                txtTrainerNo.Text = table(0)("Trainer_No").ToString
            End If

        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try
    End Sub

    Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
        grvTrainer.Enabled = False

        btnAdd.Enabled = False
        btnUpdate.Enabled = False
        btnDelete.Enabled = False

        'Enabling for the Add event
        btnSubmit.Enabled = True
        btnCancel.Enabled = True

        Mode = "INSERT"

        txtID.Text = ""
        txtName.Text = ""
        txtSurnamr.Text = ""
        txtContactNo.Text = ""
        txtClassType.Text = ""


        txtmonthlysalary.Text = GetMonthlySalary().ToString
        txtScaleID.Text = GetScaleID().ToString
        txtTrainerNo.Text = GetNextTrainerNo().ToString()


    End Sub

    Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click
        If grvTrainer.Rows.Count > 0 Then

            If MessageBox.Show("Want to delete?", "Confirm delete?", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

                Try
                    Dim connection As New OleDb.OleDbConnection
                    Dim command As New OleDb.OleDbCommand


                    connection.ConnectionString = path
                    connection.Open()

                    command.Connection = connection
                    command.CommandText = "DELETE FROM Trainer WHERE ID = @ID"


                    Dim parID = New OleDb.OleDbParameter("@ID", grvTrainer.CurrentRow.Cells("ID").Value)
                    command.Parameters.Add(parID)
                    command.ExecuteNonQuery()
                    connection.Close()
                    GetTrainers()

                Catch ex As Exception
                    MessageBox.Show(ex.ToString)
                End Try
            End If
        Else
            MessageBox.Show("There are no records to delete......")
        End If
    End Sub

    Private Sub frmTrainer_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        GetTrainers()
        btnSubmit.Enabled = False
        btnCancel.Enabled = False
        Mode = ""

    End Sub

    Private Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click

        If String.IsNullOrEmpty(txtName.Text) Then
            MessageBox.Show("Please enter a name")
            Return
        End If

        If String.IsNullOrEmpty(txtSurnamr.Text) Then
            MessageBox.Show("Please enter a surname")
            Return
        End If

        If String.IsNullOrEmpty(txtContactNo.Text) Then
            MessageBox.Show("Please enter the contact no")
            Return
        End If

        If String.IsNullOrEmpty(txtClassType.Text) Then
            MessageBox.Show("Please enter the class type")
            Return
        End If

        Select Case Mode

            Case "INSERT"

                Try
                    Dim connection As New OleDb.OleDbConnection
                    Dim command As New OleDb.OleDbCommand

                    connection.ConnectionString = path
                    connection.Open()


                    command.Connection = connection
                    command.CommandText = "INSERT INTO Trainer (Trainer_Name, Trainer_Surname,Contact_No,Class_Type,Monthly_Salary,Scale_ID,Trainer_No)VALUES(@Name, @Surname, @ContactNo, @ClassType, @MonthlySalary,ScaleID, @TrainerNo)"

                    Dim parName = New OleDb.OleDbParameter("@Name", txtName.Text)
                    Dim parSurname = New OleDb.OleDbParameter("@Surname", txtSurnamr.Text)
                    Dim parContactNo = New OleDb.OleDbParameter("@ContactNo", txtContactNo.Text)
                    Dim parClassType = New OleDb.OleDbParameter("@ClassType", txtClassType.Text)
                    Dim parMonthlySalary = New OleDb.OleDbParameter("@MonthlySalary", txtmonthlysalary.Text)
                    Dim parScaleID = New OleDb.OleDbParameter("@ScaleID", txtScaleID.Text)
                    Dim parTrainerNo = New OleDb.OleDbParameter("@TrainerNo", txtTrainerNo.Text)


                    command.Parameters.Add(parName)
                    command.Parameters.Add(parSurname)
                    command.Parameters.Add(parContactNo)
                    command.Parameters.Add(parClassType)
                    command.Parameters.Add(parMonthlySalary)
                    command.Parameters.Add(parScaleID)
                    command.Parameters.Add(parTrainerNo)

                    command.ExecuteNonQuery()
                    connection.Close()
                    GetTrainers()

                Catch ex As Exception
                    MessageBox.Show(ex.ToString)
                End Try



            Case "UPDATE"

                Try
                    Dim connection As New OleDb.OleDbConnection
                    Dim command As New OleDb.OleDbCommand


                    connection.ConnectionString = path
                    connection.Open()

                    command.Connection = connection
                    command.CommandText = "UPDATE Trainer SET Trainer_Name=@Name, Trainer_Surname=@Surname, Contact_No=@ContactNo, Class_Type=@ClassType WHERE ID = @ID"


                    Dim parName = New OleDb.OleDbParameter("@Name", txtName.Text)
                    Dim parSurname = New OleDb.OleDbParameter("@Surname", txtSurnamr.Text)
                    Dim parID = New OleDb.OleDbParameter("@ID", txtID.Text)
                    Dim parContactNo = New OleDb.OleDbParameter("@ContactNo", txtContactNo.Text)
                    Dim parClassType = New OleDb.OleDbParameter("@ClassType", txtClassType.Text)



                    'Adding Parameters to the command object
                    command.Parameters.Add(ParName)
                    command.Parameters.Add(parSurname)
                    command.Parameters.Add(parID)
                    command.Parameters.Add(parContactNo)
                    command.Parameters.Add(parClassType)


                    'Executing Parameters
                    command.ExecuteNonQuery()
                    connection.Close()
                    GetTrainers()

                Catch ex As Exception
                    MessageBox.Show(ex.ToString())

                End Try

            Case Else
                MessageBox.Show("Nothing to Submit")

        End Select

        Mode = ""
        grvTrainer.Enabled = True
        btnSubmit.Enabled = False
        btnCancel.Enabled = False

        btnAdd.Enabled = True
        btnDelete.Enabled = True
        btnUpdate.Enabled = True

    End Sub

    Private Sub grvTrainer_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles grvTrainer.CellContentClick

        Dim ID As Integer

        If Integer.TryParse(grvTrainer.CurrentRow.Cells("ID").Value.ToString(), ID) Then
            GetTrainer(ID)
        End If

    End Sub

    Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click

        grvTrainer.Enabled = True
        btnSubmit.Enabled = False
        btnCancel.Enabled = False

        btnAdd.Enabled = True
        btnDelete.Enabled = True
        btnUpdate.Enabled = True
        Mode = ""

        If grvTrainer.Rows.Count > 0 Then
            Dim ID As Integer

            If Integer.TryParse(grvTrainer.CurrentRow.Cells("ID").Value.ToString(), ID) Then
                GetTrainer(ID)
            End If

            txtID.Text = ""
            txtName.Text = ""
            txtSurnamr.Text = ""
            txtContactNo.Text = ""
            txtClassType.Text = ""
            txtmonthlysalary.Text = ""
            txtScaleID.Text = ""
            txtTrainerNo.Text = ""
        End If

    End Sub

    Private Sub btnUpdate_Click(sender As Object, e As EventArgs) Handles btnUpdate.Click

        btnAdd.Enabled = False
        btnDelete.Enabled = False
        btnUpdate.Enabled = False

        btnSubmit.Enabled = True
        btnCancel.Enabled = True

        Mode = "UPDATE"

    End Sub

    Private Sub BtnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
        Application.Exit()
    End Sub

   
End Class 

Open in new window

0
 
LVL 82

Expert Comment

by:David Johnson, CD, MVP
ID: 41812194
and just where is your search button?
0
 

Author Comment

by:Swazi Nkosi
ID: 41812203
I haven't added it. That why im asking for help so that I could add it in my code
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

Author Comment

by:Swazi Nkosi
ID: 41812233
Can anyone assist me, please
0
 

Author Comment

by:Swazi Nkosi
ID: 41812249
@DavidJohnson

Do you have the code for the search button?
0
 
LVL 82

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points (awarded by participants)
ID: 41834740
What do you want to search? Please note that I don't have your database or your forms so I cannot read your mind..

Create a Txtbox txtSearch and a submit button
Button_99_Onclick Event so something on the line of

  connection.ConnectionString = path
            connection.Open()
            command.Connection = connection
            command.CommandText = "SELECT* FROM Trainer where Trainer_NO=" + TxtSearch.text
            table.Load(command.ExecuteReader())
            connection.Close()
            grvTrainer.DataSurce = table

Open in new window

0
 
LVL 82

Expert Comment

by:David Johnson, CD, MVP
ID: 41859952
asked and answered with no feedback
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!

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

626 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