1
Answer

Problem with the query

Photo of srinivas rao

srinivas rao

15y
2.1k
1
I am using sqlserver 2000.When i run a query for the first time..it is executing in particular time like 12 sec and when i am executing the same query the next time,it is executing in more or the less time like 4 sec,14sec. If the time varies like this, my application doesn't work well. Can you give any solution for this problem?

Answers (1)

0
Photo of Nattudurai Eswaramurthy
NA 566 24.5k 12y
HI,


 i thought about it and i would probably approach it with a MultiBinding and a respective ValueConverter, i.e.

<StackPanel>
   
<StackPanel.Resources>
       
<local:ComboBoxItemsSourceFilter x:Key="ComboBoxItemsSourceFilter"/>
   
</StackPanel.Resources>
   
<ComboBox Name="cb1">
       
<ComboBox.ItemsSource>
           
<MultiBinding Converter="{StaticResource ComboBoxItemsSourceFilter}">
               
<Binding Path="Emps"/> <!-- Source collection binding -->
               
<Binding ElementName="cb2" Path="SelectedItem"/>
               
<Binding ElementName="cb3" Path="SelectedItem"/>
           
</MultiBinding>
       
</ComboBox.ItemsSource>
   
</ComboBox>
   
<ComboBox Name="cb2">
       
<ComboBox.ItemsSource>
           
<MultiBinding Converter="{StaticResource ComboBoxItemsSourceFilter}">
               
<Binding Path="Emps"/>
               
<Binding ElementName="cb1" Path="SelectedItem"/>
               
<Binding ElementName="cb3" Path="SelectedItem"/>
           
</MultiBinding>
       
</ComboBox.ItemsSource>
   
</ComboBox>
   
<ComboBox Name="cb3">
       
<ComboBox.ItemsSource>
           
<MultiBinding Converter="{StaticResource ComboBoxItemsSourceFilter}">
               
<Binding Path="Emps"/>
               
<Binding ElementName="cb1" Path="SelectedItem"/>
               
<Binding ElementName="cb2" Path="SelectedItem"/>
           
</MultiBinding>
       
</ComboBox.ItemsSource>
   
</ComboBox>
</StackPanel>
public class ComboBoxItemsSourceFilter : IMultiValueConverter
{
   
#region IMultiValueConverter Members

   
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
   
{
       
var collection = new List<object>((object[])values[0]);
       
foreach (var item in values.Skip(1))
       
{
           
if (item != null) collection.Remove(item);
       
}
       
return collection;
   
}

   
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
   
{
       
throw new NotSupportedException();
   
}

   
#endregion
}