C# Cant selectionChange using a connect database

Iam new to this. Iam having a problem where i cant get the selsection change to work the error is in this line where s.TeamTBL.TeamID == statsmain
Iam to to connect the teamID in the Teams table to the TeamID in the statsTBL

 private void Window_Loaded(object sender, RoutedEventArgs e)

            var query = from t in db.TeamTBLs
                        orderby t.Postion ascending
                        select new
            TblTeamsData.ItemsSource = query.ToList();
 private void List_Teams_SelectionChanged(object sender, SelectionChangedEventArgs e)

            string statsmain = (string)TblTeamsData.SelectedItem;

            if (statsmain != null)
                var query = (from s in db.StatsTBLs
                             where s.TeamTBL.TeamID == statsmain  ) ;


What error? You should provide relevant error messages in questions.

I am not a Linq expert but probably the problem is that there is no select in the Linq. In your first query you have a from, an orderby and then the select. The select specifies the output.

The problem seems to have nothing to do with the SelectionChange event or with connecting to the database, it seems to be a problem with the Linq.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.