473,480 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

equivalent code?

I'm a new at C# - so please forgive my ignorance. The following 2 snippets
of code seem to be fairly equivalent. Is there any advantage to using 1 over
the other? Example 2 seems to be much more efficient...

Example 1:
XmlTextReader xtr = new
XmlTextReader(HttpContext.Current.Server.MapPath(" DogData.xml"));

XmlDataDocument xdd = new XmlDataDocument();
DataSet ds = xdd.DataSet;
ds.ReadXmlSchema(xtr);
xtr.Close ();

xtr = new XmlTextReader(HttpContext.Current.Server.MapPath(" DogData.xml"));
xdd.Load(xtr);
xtr.Close();
return ds;

Example 2:
DataSet ds = new DataSet();
ds.ReadXmlSchema(HttpContext.Current.Server.MapPat h("DogData.xml"));
ds.ReadXml(HttpContext.Current.Server.MapPath("Dog Data.xml"));
return ds;

Thanks!
haiQ

Nov 12 '05 #1
1 1994
Ex.2 is much simpler. I'd choose it.

In Ex.1 you create XmlDataDocument over DataSet and feed DataSet through it.

You may want to use XmlDataDocument to treat (access or edit) DataSet as XML
tree.

Sergey

"haiQ" <ha**@discussions.microsoft.com> wrote in message
news:7E**********************************@microsof t.com...
I'm a new at C# - so please forgive my ignorance. The following 2
snippets
of code seem to be fairly equivalent. Is there any advantage to using 1
over
the other? Example 2 seems to be much more efficient...

Example 1:
XmlTextReader xtr = new
XmlTextReader(HttpContext.Current.Server.MapPath(" DogData.xml"));

XmlDataDocument xdd = new XmlDataDocument();
DataSet ds = xdd.DataSet;
ds.ReadXmlSchema(xtr);
xtr.Close ();

xtr = new
XmlTextReader(HttpContext.Current.Server.MapPath(" DogData.xml"));
xdd.Load(xtr);
xtr.Close();
return ds;

Example 2:
DataSet ds = new DataSet();
ds.ReadXmlSchema(HttpContext.Current.Server.MapPat h("DogData.xml"));
ds.ReadXml(HttpContext.Current.Server.MapPath("Dog Data.xml"));
return ds;

Thanks!
haiQ

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2487
by: Hai Nguyen | last post by:
I'm learning C sharp and do not like vb much. I'm creatiing a wepage using panel to test myself. I tried to use these code below, which is written in VB, and to transform them to c sharp but I got...
8
1400
by: Xucyr | last post by:
I can't find any "short" code to make this work without taking 100s of lines (because I have to keep repeating this process several times). But this is what I have so far: int i = 7; do {...
9
4027
by: Alan Silver | last post by:
Hello, I'm converting some old VB6 code to use with ASP.NET and have come unstuck with the Asc() function. This was used in the old VB6 code to convert a character to its ASCII numeric...
48
2689
by: Daniel Crespo | last post by:
Hi! I would like to know how can I do the PHP ternary operator/statement (... ? ... : ...) in Python... I want to something like: a = {'Huge': (quantity>90) ? True : False} Any...
14
2517
by: grid | last post by:
Hi, I have a certain situation where a particular piece of code works on a particular compiler but fails on another proprietary compiler.It seems to have been fixed but I just want to confirm if...
5
6528
by: lcw1964 | last post by:
Greetings again, I will burden the group with yet another tenderfoot question, but since conscientious googling hasn't yield a lucid answer I thought I would risk the shortcut of asking here...
8
1381
by: Jon Paal | last post by:
what is vb equivalent to this C# code ? converters failed to handle this "using (SQLiteTransaction mytransaction = myconnection.BeginTransaction())"
6
2013
by: Jon Paal | last post by:
what is vb equiv. of ++ shown in C# ?
22
7884
by: Kurien Mathew | last post by:
Hello, Any suggestions on a good python equivalent for the following C code: while (loopCondition) { if (condition1) goto next; if (condition2) goto next;
11
2878
by: gnuist006 | last post by:
Is there a Delphi equivalent in the C world or Scheme/LISP world ? Recently, Delphi is in resurgence. In Russia people are using like crazy. For example, Bolega has written a free image...
0
7044
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6739
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6929
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5337
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
2995
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2984
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
181
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.