Results 1 to 2 of 2

Thread: LINQ statement for given SQL query

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    485

    Thumbs up LINQ statement for given SQL query

    Hi,

    I used to create views for such SQL query directly into my local SQL server.
    Code:
    SELECT [Claim No], [SAP Claim No] FROM [table1]
    WHERE [Claim no] IN (
    	SELECT [Claim no] FROM [table1]
    	WHERE Code IN ('WTY_VS067', 'WTY_VS094')
    )
    GROUP BY [Claim No], [SAP Claim No]
    HAVING COUNT([Claim No]) = 2
    Number "2" in bold is corresponding to the number of codes to filter for Code field. Table consist of a total of 7 fields.

    Before creating the view, I would have to trim 4 rows off a CSV file then import into a new table in my local SQL server.

    These are too much of work, so I decided to code the program in VB.net 2010. Now that I have successfully read the CSV file and display them onto a DataGridView (bound to a datatable). With another ListView of carefully selected fields, user can choose the fields to filter their records (fields highlighted above in bold) accordingly.

    Seeing that I have my data in Datatable and I guess there is no way to query a datatable records using pure SQL statement. I thought of resorting to using LINQ.

    Please help with the LINQ statement in order to achieve the same result of the above SQL statement.

    Thank you for any input.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    485

    Re: LINQ statement for given SQL query

    Can I bump this without posting a reply?

    Anyone can help me?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width