With command
.Connection = connection
.CommandText = search_query
.Parameters.Clear()
.Parameters.Add(New SqlParameter With {.ParameterName = "@menu_name", .SqlDbType = SqlDbType.VarChar, .Value = formFoodMenu.txtMenuName.Text})
result = .ExecuteScalar()
If result > 0 Then
MsgBox("Menu name is already exists!", MsgBoxStyle.Exclamation, "Add Menu")
Else
insert_query = "INSERT INTO tblfood_menu(menu_name) VALUES(@menu_name);"
command = New SqlCommand
With command
.Connection = connection
.CommandText = insert_query
.Parameters.Clear()
.Parameters.Add(New SqlParameter With {.ParameterName = "@menu_name", .SqlDbType = SqlDbType.VarChar, .Value = formFoodMenu.txtMenuName.Text})
result = .ExecuteNonQuery()
If result = 0 Then
MsgBox("Error in adding menu!", MsgBoxStyle.Exclamation)
Else
MsgBox("Successfully added menu!", MsgBoxStyle.Information)
End If
End With
End If
End With