Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ADO.NET, datasets, XMLDOM, VFP 8?
Message
From
29/10/2003 08:13:48
 
 
To
28/10/2003 18:24:56
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00843864
Message ID:
00844008
Views:
25
>I have a software created with visual studio 2003. This is complete set of
>webservices, to control my inventory software. The functions return a
>datasets or XMLDocs. I´m trying to consume this datasets or XMLDocs in VFP
>8.0. My problem is when I have more 2000 records, the curfill function takes
>a long of time to fillout the cursor, I´ve been test the function, and when
>1000 records the cursorfill takes about 0.8 seconds, with 2000 records about
>2.8 seconds, but with 3000 records takes about 10 to 12 seconds, with 5000
>records takes about 60 seconds, as you can see it´s exponencial.
>
>My questions are:
>1. What is the better way to recover a .net dataset from VFP?.
>2.What is the maximun size that supported by cursorfill in XML?.
>3. An XMLAdapter recover the dataset faster than a cursorfill method?
>4. Is there a library or something like that to covert xmltocursor in
>a faster way than the original VFP functions.?
>

Hi Carlos,

My tests for XMLTOCURSOR and XMLAdapter show that the most efficient way to process DataSet from a Web Service is:
1) Web Service returns DataSet.
2) Data and schema XMLDOMNodes are attached using XMLAdapter.Attach method without converting them to strings. This, by the way, should allow to overcome VFP limit for maximum memvar size when working with big XML documents.

Results when Web Service is called from the same machine:
loService1.GetOrderdetails():          0.938

XMLAdapter.Attach:          0.078
Fill through XMLAdapter after Attach
Time:          1.063
Records:       6465
XMLSize     1312052
Total time:            2.079

loService1.GetOrderdetails1():          1.234

XMLAdapter.LoadXML:          0.281
Fill through XMLAdapter after LoadXml
Time:         43.813
Records:       6465
XMLSize    1178568
Total time:           45.328

Fill through XMLTOCORSOR with schema.
Time:         44.859
Records:       6465
XMLSize    1178568
Total time:          46.093

loService1.GetOrderdetails2():          1.203

Fill through XMLTOCORSOR without schema.
Time:         90.469
Records:       6465
XMLSize    1177646
Total time:          91.672
Results when Web Service is called from another machine:
loService1.GetOrderdetails():          0.906

XMLAdapter.Attach:          0.078
Fill through XMLAdapter after Attach
Time:         21.875
Records:       6465
XMLSize     1312052
Total time:           22.859

loService1.GetOrderdetails1():          9.359

XMLAdapter.LoadXML:          0.250
Fill through XMLAdapter after LoadXml
Time:         48.172
Records:       6465
XMLSize    1178568
Total time:           57.781

Fill through XMLTOCORSOR with schema.
Time:         35.625
Records:       6465
XMLSize    1178568
Total time:          44.984

loService1.GetOrderdetails2():          9.562

Fill through XMLTOCORSOR without schema.
Time:         70.734
Records:       6465
XMLSize    1177646
Total time:          80.296
VFP code:
CLEAR
SET MULTILOCKS ON
CLOSE DATABASES all

LOCAL loService1 AS "XML Web Service"
* LOCAL loService1 AS "MSSOAP.SoapClient30"
* Do not remove or alter following line. It is used to support IntelliSense for your XML Web service.
*__VFPWSDef__: loService1 = http://localhost/WebService1/Service1.asmx?WSDL , Service1 , Service1Soap
LOCAL loException, lcErrorMsg, loWSHandler

loWSHandler = NEWOBJECT("WSHandler",IIF(VERSION(2)=0,"",HOME()+"FFC\")+"_ws3client.vcx")
loService1 = loWSHandler.SetupClient("http://localhost/WebService1/Service1.asmx?WSDL", "Service1", "Service1Soap")
* Call your XML Web service here.  ex: leResult = loService1.SomeMethod()

SecondsBefore=SECONDS()
retVal=loService1.GetOrderdetails()
elapsed0=SECONDS()-SecondsBefore
?"loService1.GetOrderdetails():",elapsed0
?
LOCAL oXA as XMLAdapter

oXA=CREATEOBJECT("XMLAdapter")

SecondsBefore=SECONDS()
oXA.Attach(retVal.Item(1),retVal.Item(0))
elapsed1=SECONDS()-SecondsBefore
?"XMLAdapter.Attach:",elapsed1

LOCAL oCA as CursorAdapter
oCA=CREATEOBJECT("CursorAdapter")

oCA.DataSourceType="XML"
oCA.SelectCmd="oXA.TAbles.Item(1)"
oCA.Alias="OrderDetails"

SecondsBefore=SECONDS()
IF !oCA.CursorFill()
	AERROR(aerrs)
	DISPLAY MEMORY LIKE aerrs
ENDIF
elapsed2=SECONDS()-SecondsBefore
?"Fill through XMLAdapter after Attach"
?"Time:",elapsed2
?"Records:",RECCOUNT("OrderDetails")
?"XMLSize",LEN(retVal.Item(1).xml)+LEN(retVal.Item(0).xml)
?"Total time:",elapsed1+elapsed2+elapsed0

retval=null
oXA.ReleaseXML(.T.)
USE IN OrderDetails
?
SecondsBefore=SECONDS()
retval=loService1.GetOrderdetails1()
elapsed0=SECONDS()-SecondsBefore
?"loService1.GetOrderdetails1():",elapsed0
?
SecondsBefore=SECONDS()
oXA.LoadXML(retval)
elapsed1=SECONDS()-SecondsBefore
?"XMLAdapter.LoadXML:",elapsed1

SecondsBefore=SECONDS()
IF !oCA.CursorFill()
	AERROR(aerrs)
	DISPLAY MEMORY LIKE aerrs
ENDIF
elapsed2=SECONDS()-SecondsBefore
?"Fill through XMLAdapter after LoadXml"
?"Time:",elapsed2
?"Records:",RECCOUNT("OrderDetails")
?"XMLSize",LEN(retVal)
?"Total time:",elapsed1+elapsed2+elapsed0

oXA.ReleaseXML(.T.)
USE IN OrderDetails
?
oCA.SelectCmd=retval

SecondsBefore=SECONDS()
IF !oCA.CursorFill()
	AERROR(aerrs)
	DISPLAY MEMORY LIKE aerrs
ENDIF
elapsed2=SECONDS()-SecondsBefore
?"Fill through XMLTOCORSOR with schema."
?"Time:",elapsed2
?"Records:",RECCOUNT("OrderDetails")
?"XMLSize",LEN(oCA.SelectCmd)
?"Total time:",elapsed2+elapsed0
USE IN OrderDetails

?
SecondsBefore=SECONDS()
retval=loService1.GetOrderdetails2()
elapsed0=SECONDS()-SecondsBefore
?"loService1.GetOrderdetails2():",elapsed0
?
oCA.SelectCmd=retval

SecondsBefore=SECONDS()
IF !oCA.CursorFill()
	AERROR(aerrs)
	DISPLAY MEMORY LIKE aerrs
ENDIF
elapsed2=SECONDS()-SecondsBefore
?"Fill through XMLTOCORSOR without schema."
?"Time:",elapsed2
?"Records:",RECCOUNT("OrderDetails")
?"XMLSize",LEN(oCA.SelectCmd)
?"Total time:",elapsed2+elapsed0
USE IN OrderDetails
Web Service code:
private String sqlCmd=
	"SELECT * from Orderdetails"
	+" UNION ALL SELECT * from Orderdetails"
	+" UNION ALL SELECT * from Orderdetails";

[WebMethod]
public DataSet GetOrderdetails()
{
	OleDbConnection nwindConn = new OleDbConnection("Provider=VFPOLEDB.1;"+
				@"Data Source=C:\Program Files\Microsoft Visual FoxPro 8\"+ 
				@"Samples\Northwind\Northwind.dbc;Collating Sequence=MACHINE");

	OleDbCommand selectCMD = new OleDbCommand(sqlCmd, nwindConn);

	OleDbDataAdapter OrderdetailsDA = new OleDbDataAdapter();
	OrderdetailsDA.SelectCommand = selectCMD;

	DataSet OrderDetailsDataSet=new DataSet("OrderDetailsDataSet");
	OrderdetailsDA.Fill(OrderDetailsDataSet, "Orderdetails");

	return OrderDetailsDataSet;
}

[WebMethod]
public String GetOrderdetails1()
{
	OleDbConnection nwindConn = new OleDbConnection("Provider=VFPOLEDB.1;"+
		@"Data Source=C:\Program Files\Microsoft Visual FoxPro 8\"+ 
		@"Samples\Northwind\Northwind.dbc;Collating Sequence=MACHINE");

	OleDbCommand selectCMD = new OleDbCommand(sqlCmd, nwindConn);

	OleDbDataAdapter OrderdetailsDA = new OleDbDataAdapter();
	OrderdetailsDA.SelectCommand = selectCMD;

	DataSet OrderDetailsDataSet=new DataSet("OrderDetailsDataSet");
	OrderdetailsDA.Fill(OrderDetailsDataSet, "Orderdetails");

	StringWriter strXML=new StringWriter();

	OrderDetailsDataSet.WriteXml(strXML,XmlWriteMode.WriteSchema);	
	return strXML.ToString();
}

[WebMethod]
public String GetOrderdetails2()
{
	OleDbConnection nwindConn = new OleDbConnection("Provider=VFPOLEDB.1;"+
		@"Data Source=C:\Program Files\Microsoft Visual FoxPro 8\"+ 
		@"Samples\Northwind\Northwind.dbc;Collating Sequence=MACHINE");

	OleDbCommand selectCMD = new OleDbCommand(sqlCmd, nwindConn);

	OleDbDataAdapter OrderdetailsDA = new OleDbDataAdapter();
	OrderdetailsDA.SelectCommand = selectCMD;

	DataSet OrderDetailsDataSet=new DataSet("OrderDetailsDataSet");
	OrderdetailsDA.Fill(OrderDetailsDataSet, "Orderdetails");

	StringWriter strXML=new StringWriter();

	OrderDetailsDataSet.WriteXml(strXML,XmlWriteMode.IgnoreSchema);	
	return strXML.ToString();
}
Thanks,
Aleksey.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform