Solved

Search button

Posted on 2016-09-23
7
17 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
  • 4
  • 3
7 Comments
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
Comment Utility
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 78

Expert Comment

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

Author Comment

by:Swazi Nkosi
Comment Utility
I haven't added it. That why im asking for help so that I could add it in my code
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:Swazi Nkosi
Comment Utility
Can anyone assist me, please
0
 

Author Comment

by:Swazi Nkosi
Comment Utility
@DavidJohnson

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

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points (awarded by participants)
Comment Utility
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 78

Expert Comment

by:David Johnson, CD, MVP
Comment Utility
asked and answered with no feedback
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

17 Experts available now in Live!

Get 1:1 Help Now