jubimy

I've played around with the new March CTP of Orcas and tried some samples from documentation.

First sample runs well:

Sub Sample1()
Dim db As New Dialog1DataContext ' access to SQL2005 express db
Dim query = From p In db.DiaVorschlagsWertes _ ' access table
Where p.ChoiceListKey = "Abteilung" _
Select p
GridV1.DataSource = query
GridV1.DataBind()
End Sub

But in the second sample I've got a compiler error in the select operator:

Sub Sample2()
Dim db As New Dialog1DataContext
Dim query = From p In db.DiaVorschlagsWertes _
Where p.ChoiceListKey = "Abteilung" _
select new {p.ChoiceListKey, p.TextValue}
GridV1.DataSource = query
GridV1.DataBind()
End Sub

The attributes (ChoiceListkey, TextValue) of object p are approved.
The complier error is: "type or'With' expected" and is shown directly after keyword "New"

Maybe changes in the syntax between May06 CTP and March07 CTP
Are any samples available to vb9 and OrcasMarchCTP

Thanks a lot for help



Re: Visual Basic 2008 (Pre-release) problems with vb9 syntax

sravanik

Try the following,

Sub Sample2()
Dim db As New Dialog1DataContext
Dim query = From p In db.DiaVorschlagsWertes _
Where p.ChoiceListKey = "Abteilung" _
select p.ChoiceListKey, p.TextValue
GridV1.DataSource = query
GridV1.DataBind()
End Sub

The above snippet should compile and work fine. If you notice, I've taken out the "new" keyword. This is because "select" will automatically create a anonymous type for you when you are projecting more than 1 variable.

Hope that helps,