[Q] LINQ to XML - help need from SQL

GFR_2009

Member
Oct 9, 2009
37
0
0
Hi there,

I'm porting an app which uses SQL to query a SQLCE db.

Now under WP7 I switched over to XML files.

Can anyone help me to "translate" the following SQL sentence to Linq to XML ?

Code:
        Dim SQL As String = String.Empty
        Dim USERENTRY As String = String.Empty

        SQL = "SELECT Info.INFO_COMMENTS FROM Names INNER JOIN Info ON Names.NAME_ID = Info.INFO_NAME_ID "
        SQL = SQL + "WHERE (Names.PARENTS_NAME_ID = " & "'" & USERENTRY & "') "
        SQL = SQL + "GROUP BY Info.INFO_COMMENTS "
        SQL = SQL + "ORDER BY Info.INFO_COMMENTS"
My skills are very low right now to deal with this...

On the other hand, if someone can point me to a some kind of tool to make the conversion or a great tutorial, that will be great too!

Thanks in advance for any help.

Cheers
 

timfoster

Senior Member
Feb 13, 2007
51
1
0
I'm not Linc expert, but the quickest way to get your sql server output into an xml format is to use the FOR XML statement:

SELECT * FROM TABLE FOR XML

Whether this is the correct syntax for Linc, I don't know, but it may point you down the right path.
Google "sql server for xml"
 

The_badger_man

New member
Dec 5, 2009
1
0
0
Hello,

Your SQL request depends on your db schema. The Linq to XML request over a XML will depend on the XML structure.
So we need to see your XML file to help you.
 

DaveShaw

Senior Moderator Emeritus + Wiki Bureaucrat
Dec 4, 2007
8,771
496
83
Huddersfield
www.taeguk.co.uk
Hello,

Your SQL request depends on your db schema. The Linq to XML request over a XML will depend on the XML structure.
So we need to see your XML file to help you.
As the Badger says, post some sample XML and we can take a look...

Also, check out Linqpad for a collection of Linq To Xml samples and a great way to learn Linq in general (it will change your coding ;))