troubleshooting Question

Visual Studio 2008 Multiselection querry with LINQ Query

Avatar of sanlorenzo
sanlorenzo asked on
Programming TheoryMicrosoft ApplicationsVisual Basic.NET
3 Comments1 Solution587 ViewsLast Modified:
With Visual Studio 2008 and SQL Server 2005 I have a Form where i drag the  data Class (tbl_Name )  Linked to a Table  Named  tbl_Name

The Table has 5 Column : NameID/Name/Town/Country/Continent

So the Form show a Grid representing the tbl_Name with the 5 column
I have in same form Toolstrip    2 combo box named as follow :

ToolStripComboBox1    It Populate Taking Data from the column Continent
ToolStripComboBox2   It Populate Taking  Data from the collumn Country

 In the Form I have also a Button : Button3 that i use to trigger the filter action

I am using the following code to filter the Grid by Continent and by Country and it works very well

 Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        Dim MultyQuerry = From tbl_Name In db.tbl_Names _
                                Where tbl_Name.Continent = Me.ToolStripComboBox1.SelectedItem.ToString _
                                And tbl_Name.Country = Me.ToolStripComboBox2.SelectedItem.ToString _
                                Select tbl_Name
        Me.Tbl_NameBindingSource.DataSource = MultyQuerry
End Sub

Now let me come to my Problem

All is working if i have both Combo Box with a value :

But it give me error if one of the comboBox is empty

Is anyone helping me to change my code so to handle the Null value ???

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros