title: C# database selection
body: <p>I have two databases. The first one is shown via a <code>ListBox</code>, and the second one via a <code>ListView</code>. I want to be able to show some information in the <code>ListView</code> based on the chosen <code>ListBox</code> element, but my code doesn't work.</p>
  
  <pre><code>private void DpListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  {
      L.InitReadOnly(false, NameF, LastNameF, AgeF, DepartmentF, ProfessionF, SalaryF);
      L.InitReadOnly(false, Name4, LastName4, Age4, Department4, Profession4, Salary4);
      int counter = 0;
      IEnumerable&lt;Employee&gt; critCareEmp;
      critCareEmp = L.EmpUpdate(counter, Emp, DpListBox, Ep);
  
      SqlConnection connection = new SqlConnection(connectionString);
      SqlDataAdapter adapter = new SqlDataAdapter();
      Console.WriteLine(DpListBox.SelectedValue.ToString());
      SqlCommand command = new SqlCommand($@"SELECT * FROM Employee WHERE Dep_nt={DpListBox.SelectedValue}", connection);
      adapter.SelectCommand = command;
      DataTable dataTable1 = new DataTable();
      adapter.Fill(dataTable1);
      Ep.ItemsSource = dataTable1.DefaultView;
  }
  </code></pre>
  
  <p>It seems that I need <code>DpListBox.SelectedValue</code> to be some kind of string, but it's not.</p>