>Hi People
>
>How to retrieve to a Visual FoxPro application a field type XML from a Sql Server Table using SQL Pass-Through or any other method of acessing data?
>
>TIA
You would use ADO. Here is a sample using ADO and browsing via a CursorAdapter as well:
#Define SQLCONNECTION "Provider=SQLNCLI;Server=.\sqlexpress;Integrated Security=SSPI"
*!* ADO CursorAdapter
Local o As CursorAdapter
o = Createobject('caADO', "ContactInfo", SQLCONNECTION, ;
"select firstName,lastName,AdditionalContactInfo from AdventureWorks.Person.Contact" )
o.CursorSchema = "firstName c(30),lastName c(30),AdditionalContactInfo m"
o.CursorFill(.T.)
Select ContactInfo
BROWSE
*!* Select ContactInfo
*!* BROWSE valid ShowXML(AdditionalContactInfo)
*!* FUNCTION ShowXML(tcXML)
*!* XMLTOCURSOR(m.tcXML,'myCursor')
*!* SELECT myCursor
*!* BROWSE nowait
Define Class caADO As CursorAdapter
Procedure Init
Lparameters tcAlias,tcConn, tcSQL
This.Alias = m.tcAlias
This.AddProperty('oConn', Newobject("ADODB.Connection"))
This.AddProperty('oRS', Newobject("ADODB.Recordset"))
This.oConn.ConnectionString = m.tcConn
This.oConn.Open()
This.oRS.ActiveConnection = This.oConn
This.DataSourceType = "ADO"
This.Datasource = This.oRS
This.SelectCmd = tcSQL
Endproc
Enddefine
If you use ODBC driver then be sure to cast to varchar(8000). That would limit your xml field content size but still is a workaround to VFP's interpretation bug.
Cetin