Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
XML to datarow
Message
From
14/05/2013 08:47:26
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01573699
Message ID:
01573765
Views:
45
Likes (1)
>>>
>>> if m.booking_id > 0 and m.podbktype=2     && are we changing the schedule of a "book entire" booking?
>>>&& are there any existing max4sale restrictions (besides the current one)?  If so, that's a conflict
>>>            lcSQLReturn=.mysqlexec("select start_time, end_time, type, lessontype, max_sale, "+;
>>>               "id, e_mail_l1, mail1_sent, e_mail_l2, mail2_sent "+;
>>>               "from dbo.max4sale where start_time<"+.VFP2SQL(m.end_time)+" and end_time>"+;
>>>               .VFP2SQL(m.start_time)+" and type=5 and pod_id="+;
>>>               .VFP2SQL(padr(m.resource1,12))+" and not exists(select booking_id from dbo.b_sched where start_time<"+;
>>>               .VFP2SQL(m.end_time)+" and end_time>"+.VFP2SQL(m.start_time)+" and podbktype=2 and resource1="+;
>>>               .VFP2SQL(padr(m.resource1,12))+" and booking_id = "+.VFP2SQL(m.booking_id)+")", 'csrMax', program())
>>>
>>>
>>>In other words, in VFP I converted passed XML string into individual variables for each column.
>>
>>Not important, but I still don't see it. AFAICS you just need to grab a few values from the XML to use in a SQL statement. If that's the case why bother building a comparatively heavy datatable to do the job. Linq to XML, for example, would be simpler and cleaner.
>
>The problem here is that some of the fields may also contain "XML" like elements. I think XML may choke on that.
>
>Here is a more complete sample I tried
>
>
>string xml = @"<tcactionlist><DEPARTMENT>ACTIVITIES</DEPARTMENT>
><DISPLAY_MSG>P Spade Sam Book Many Pod 1921000000</DISPLAY_MSG><END_TIME>05/13/2013 05:00:00 PM</END_TIME>
><EXPERIENCE></EXPERIENCE><EXPORTD_ON>01/01/1900 12:00:00 AM</EXPORTD_ON>
><FIRST_NAME>SAM</FIRST_NAME><FLEX_TSPAN></FLEX_TSPAN><FORECOLOR></FORECOLOR><GroupMembers>
><Pri_Key1>62</Pri_Key1><First1>SAM</First1><Last1>SPADE</Last1><GstNo1></GstNo1><Pri_Key2>63</Pri_Key2>
><First2>TONY</First2><Last2>TUNE</Last2><GstNo2></GstNo2><Pri_Key3>64</Pri_Key3><First3>FRANK</First3>
><Last3>FAST</Last3><GstNo3></GstNo3><Pri_Key4>65</Pri_Key4><First4>BILLIE</First4><Last4>BLADES</Last4>
><GstNo4></GstNo4></GroupMembers><GST_NAME>Spade Sam</GST_NAME><GUEST_NO>1897000000</GUEST_NO>
><GUEST_NO1>1897000000.00000</GUEST_NO1><RESERV_NO>0</RESERV_NO><RESOURCE1>BOOKMANY</RESOURCE1>
><RESRC_REQ1></RESRC_REQ1><SALESPOINT>TKT02</SALESPOINT><SEX></SEX><SNB_LEVEL></SNB_LEVEL>
><START_TIME>05/13/2013 03:30:00 PM</START_TIME><TCH_LEVEL></TCH_LEVEL><TELE_LEVEL></TELE_LEVEL>
><TEMP_NAME></TEMP_NAME><TIMESLOT></TIMESLOT><TO_REVENUE>01/01/1900 12:00:00 AM</TO_REVENUE><TRANS_NO>114007000</TRANS_NO>
><UPG_BY></UPG_BY><WHICHLEVEL></WHICHLEVEL><XLD_END>01/01/1900 12:00:00 AM</XLD_END>
><XLD_START>01/01/1900 12:00:00 AM</XLD_START><XTRA_BOOKS></XTRA_BOOKS></tcactionlist>";
>			DataSet ds = new DataSet();
>			ds.ReadXml(new XmlTextReader(new StringReader(xml)));
>			
>foreach (DataRow row in ds.Tables[0].Rows)
>{
>	foreach (DataColumn column in ds.Tables[0].Columns)
>	{
>		Console.WriteLine (column.ColumnName + ":  " + row[column.ColumnName].ToString());	
>	}
>}
>
>Look at GroupMember column.

Don't know what you get when you run this. The GroupMember elements will be written to Table[1].

>Also, I may need to save all information into the table - here I am a bit lost because the new datatable I receive has different order of the columns than the actual table. Is there a way to save info without listing every individual column?

This goes back to my earlier post. You will still have to 'manually' move the elements from the ReadXML table into the actual table.
Still think it better to create a row for the real table and populate it from the XML using one of the XML libraries.....
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform