Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
XML DataType
Message
From
22/02/2010 07:45:46
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
21/02/2010 15:03:58
Moacyr Zalcman
Independent Consultant
São Paulo, Brazil
General information
Forum:
Microsoft SQL Server
Category:
Other
Title:
Environment versions
SQL Server:
SQL Server 2005
Application:
Desktop
Miscellaneous
Thread ID:
01450144
Message ID:
01450188
Views:
95
This message has been marked as the solution to the initial question of the thread.
>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform