tags:

views:

54

answers:

1

I have a form in which I am able to list a parent table using datagridview. I also have a child payment table that list all the payments made. I have added a combo box so I can make my search more efficient. Everythhing worked great until I added to box. Now I get this error==

InValidCastException == Conversion from string "" to type 'Double' is not valid.

Can you please helpme correct this?? I am using SQL Server 2005 and Visual Studios 2008.

Dim teamList = From Bowler In Db.Bowlers _ Where Bowler.TeamNumber <> "" _ Order By Bowler.TeamNumber _ Select Bowler.TeamNumber For Each TeamNumber In teamList Me.ToolStripComboBox1.Items.Add(TeamNumber) Next End Sub

Thanks Cheryl

+2  A: 

I assume Bowler.TeamNumber is a Double datatype. This means you cannot do

Bowler.TeamNumber <> ""

instead you can only do

Bowler.TeamNumber <> 0

or

Bowler.TeamNumber <> NULL

EDIT: Following on from comment, you need something like this:

Dim teamList = (From Bowler In Db.Bowlers _ 
Where Bowler.TeamNumber <> "" _ 
Order By Bowler.TeamNumber _ 
Select Bowler.TeamNumber ).Distinct()

For Each TeamNumber In teamList 
Me.ToolStripComboBox1.Items.Add(TeamNumber) 
Next
ck
Thank you so much. I put the "0" everywhere but there.That work great. I can now see the numbers. But, it is now doubling the numbers. There are 4 bowlers per team which means the number "1" will show up 4 times. And it does not populate the grids with info that is in there. Any suggestions. heryl
I've updated my post with a solution
ck
Thank you. It now only show one number. It is still not populating the tables. Any suggestions?
What tables are you trying to update? There isn't any code for that...
ck
I git it working.Thanks for your help. CheryDim bowlerQuery = From Bowler In Db.Bowlers _ Where Bowler.TeamNumber = Me.ToolStripComboBox1.SelectedItem.ToString() _ Select Bowler Me.BowlerBindingSource.DataSource = bowlerQuery