I am trying to display a message box if the string entered in the textbox was not found in the database
Also, if the enter button is pressed and the textbox is blank, then a msgbox should say "A value must be entered"
I have tried everything to my knowledge and vb.net does not like it.
Code:Private Sub ButtonLookup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonLookup.Click Try Dbconnect.Open() ' Try Block - Connects To The Database. Displays An Error If It Can't. Dim DbAdapter As New MySqlDataAdapter("SELECT * FROM Itemlist WHERE Barcode = '" & TextBoxItemInput.Text & "'", Dbconnect) Dim DbDataSet As New DataSet DbAdapter.Fill(DbDataSet, "Itemlist") Dim DbTable As DataTable = DbDataSet.Tables("Itemlist") For Each row As DataRow In DbTable.Rows Dim ItemSku As Integer = row("ItemSku").ToString() Dim ItemName As String = row("ItemName").ToString() Dim Barcode As String = row("Barcode").ToString() Dim Price As Decimal = row("Price").ToString() ItemGridView.Rows.Add(Barcode, ItemName, 1, Price, Price) LabelStatus.Text = "Item Added" LineDisplay.ClearText() LineDisplay.DisplayText(ItemName & " $" & Price) ItemGridView.ClearSelection() TextBoxItemInput.Clear() Next




Reply With Quote