locked
DLinq Hands-On Lab for VB RRS feed

  • Question

  • Hello,

    In Lab 1 I entered the code as shown.  The following command code gives the error "End of statement expected"

    Dim custs = _

    From c In Customers _

    Where c.City = "London" _

    Select c

    Any ideas what might be wrong?

    Thanks,

    Tom

     

    Tuesday, October 24, 2006 8:34 PM

Answers

  • Hi Genevieve,

    Just to be sure I have the May CTP installed, I download it again from MSDN.  Then I installed it and selected the "Repair" option.

    Now the commands are recognized, and the program runs.

    Sorry, I guess something got corrupted.

    Thanks for your help.

    Regards,

    Tom

     

    Thursday, October 26, 2006 2:04 PM

All replies

  • Can you paste in the code from your entire file? I do not see any problems with the code you have provided so far.
    Wednesday, October 25, 2006 6:13 PM
  • Hi Genevieve,

    Thanks for taking time to look at this issue.  I have copied the code from the original WORD document several times, but I still do not see what might be causing this.

    Module Module1

    <Table(Name:="Customers")> _

    Public Class Customers

    <Column(Id:=True)> _

    Public CustomerID As String

    Private _City As String

    <Column(Storage:="_City")> _

    Public Property City() As String

    Get

    Return Me._City

    End Get

    Set(ByVal value As String)

    Me._City = value

    End Set

    End Property

    End Class

    Sub Main()

    ' Use a standard connection string

    Dim db As New DataContext _

    ("c:\program files\linq preview\data\northwnd.mdf")

    ' Get a typed table to run queries

    Dim Customers As Table(Of Customers) = db.GetTable(Of Customers)()

    ' Attach the log showing generated SQL to console

    ' This is only for debugging / understanding the working of

    ' DLinq

    db.Log = Console.Out

    ' Query for customers in London

    Dim custs = _

    From c In Customers _

    Where c.City = "London" _

    Select c

    For Each cust In custs

    Console.WriteLine("ID=" & cust.CustomerID & ", City=" & _

    cust.City)

    Next

    Console.ReadLine()

    End Sub

    End Module

    Thanks again for your help.

    Tom

     

    Wednesday, October 25, 2006 6:45 PM
  • That code looks okay to me. I am wondering whether the LINQ-enabled compiler is being used or not. Can you open the .vbproj file in notepad and look at the line that starts with "<Import Project". It should look like this:

    <Import Project="$(ProgramFiles)\LINQ Preview\Misc\Microsoft.VisualBasic.LINQ.targets" />

    Wednesday, October 25, 2006 7:52 PM
  • Hi Genevieve,

    Yes, the vbproj file had that line in it. 

    Also, on the line "For Each cust In custs" there is a blue squiggle line under "cust" and "custs" indicating they are not defined.

     

    Thanks for any suggestions,

    Tom

     

    Wednesday, October 25, 2006 8:13 PM
  • Tom,

    I noticed that the 'From' and 'Where' keywords in your query are not blue, which signifies that the compiler does not recognize the new LINQ language features in VB. Are you using the May CTP, and are you 100% sure that you chose one of the LINQ Preview templates when you created the project in Visual Studio?

    Wednesday, October 25, 2006 9:07 PM
  • Hi Genevieve,

    Just to be sure I have the May CTP installed, I download it again from MSDN.  Then I installed it and selected the "Repair" option.

    Now the commands are recognized, and the program runs.

    Sorry, I guess something got corrupted.

    Thanks for your help.

    Regards,

    Tom

     

    Thursday, October 26, 2006 2:04 PM