C# Connected database, selection change Error

Iam trying to learn how to connect database to c# but iam having trouble with a selection change. i dont know what this means

public partial class MainWindow : Window
    {
        FinalEPLEntities db = new FinalEPLEntities();
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var query = from t in db.TeamTBLs
                        select t.TeamName;
            lbxListvob.ItemsSource = query.ToList();
        }

        private void lbxListvob_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string company = (string)lbxListvob.SelectedItem;

            if(company != null)
            {
                var query = (from deatils in db.StatsTBLs
                             where deatils.TeamTBL.TeamName == company
                             select deatils.TopForward);
                plxx.Text = string.Format("Total is {0}", query);
            }
        }
    }

You’re getting too generic here. All you’re doing is throwing the LINQ query into a generic var, so the string is just going to try to convert that to a string.

You’ll want to load it into some sort of object with defined structure then query off that.

This is a good reference to hopefully get you further: https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/ef/language-reference/query-execution

What do you mean by this? the first thing I see after this is a SQL query. Then I see some code. I do not know what you are asking about.

As best as i can tell, your question is not about connecting to the database. You are probably trying to ask about the SQL query or about a Linq query.

Sorry for being to generic, what i’am trying to do is then i click on EG Liverpool I want it to show TopForward for liverpool and if i click on manCity I want to show ManCitys topForward in a text box.

Sorry if i’am still being generic but i don’t really know any other way to explain it.

Got it working in the end. thanks for helping @DaveMaxwell @SamuelCalifornia
From this

to this

plxx.Text = string.Format("Team name {0}\n{1}", company, string.Join(",", query));
````