hi guys i wanna ask how to make warning messages when a user clicks the search button and found no record with what he input.

here is my stored proc

ALTER PROCEDURE dbo.Searchbylastname
	/*
	(
	@parameter1 int = 5,
	@parameter2 datatype OUTPUT
	)
	*/
	(
	@value1 varchar(50)
	)
AS
	/* SET NOCOUNT ON */
	SElect * from admissionRecord
	where lname=@value1

and here's my other code

Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        If ComboBox1.Text = "Med Staff ID" Then
            searchbyMedStaffID()
        ElseIf ComboBox1.Text = "Department ID" Then
            searchbyMedStaffDeptID()
        End If
    End Sub

    Private Sub searchbyMedStaffID()
        Dim StrSQL As String = "Searchbylastname"
        classLibrary = New ConnectionLibrary
        classLibrary.openConnection(strConnection)

        If Not classLibrary.isConnectionOpen() Then
            Exit Sub
        End If

        classLibrary.initializeCommand(StrSQL)
        classLibrary.addParameter("@value1", SqlDbType.VarChar, txtSearch.TextLength, txtSearch.Text)
        objCommand.ExecuteNonQuery()
        displayresult()
    End Sub

Can you just use a message box if there is no result?

MsgBox("YOUR MESSAGE GOES HERE")

or

MsgBox(stringOfCode)

Use a simple If statement around it.
Hope this helps.

Check out this thread for "a simple If statement around it".

hi thanks i already tried but i think i got the wrong logic of putting the msgbox

show how far u trying it..
just post the codes where u have a wrong logic of put a msgbox..

Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        Dim objDt As New DataTable

        If ComboBox1.Text = "Med Staff ID" Then
            searchbyMedStaffID()

        ElseIf objDt.Rows.Count < 1 Then
            MessageBox.Show("No records found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

        End If
        If ComboBox1.Text = "Department ID" Then
            searchbyMedStaffDeptID()

            If objDt.Rows.Count < 1 Then
                MessageBox.Show("No records found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        End If
        If ComboBox1.Text = "Lastname" Then
            searchbyMedStaffLastname()

            If objDt.Rows.Count < 1 Then
                MessageBox.Show("No records found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        End If
        If ComboBox1.Text = "Firstname" Then
            searchbyMedStaffFirstname()

            If objDt.Rows.Count < 1 Then
                MessageBox.Show("No records found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If

        End If


        If txtSearch.Text = "" Then
            MessageBox.Show("You must enter information!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If



    End Sub

here

NIce Logic

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.