473,320 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to convert VBNet coding to C#Net coding to Create XML file

126 100+
I am having problem trying to convert VBNET2008 coding of creating XML File using C#NET2008.

VBNETCoding version
Expand|Select|Wrap|Line Numbers
  1.  Do While DataReader.Read
  2.         'XML Element format
  3.  
  4.         xmlWriter.WriteStartElement("row")
  5.         For i = 0 To (DR.FieldCount - 1)
  6.                   xmlWriter.WriteStartElement(DR.GetName(i))
  7.                   xmlWriter.WriteString(DR.GetValue(i).ToString)
  8.                   xmlWriter.WriteEndElement()
  9.          Next
  10.          xmlWriter.WriteEndElement()    
  11.  
  12.     Loop
  13.     xmlWriter.WriteEndElement() 
---------------------------------------------------------------------
Tried to do it using C#NET but failed to do it:
Expand|Select|Wrap|Line Numbers
  1.  
  2. while ( DataReader.Read() )   
  3.      {
  4.           XmlWriter.WriteStartElement("row");
  5.           for (int i = 0, DataReader.FieldCount -1, i + 1 ) 
  6.             { 
  7.                   xmlWriter.WriteStartElement(DataReader.GetName(i));
  8.                   xmlWriter.WriteString(DataReader.GetValue(i).ToString);
  9.                   xmlWriter.WriteEndElement(); 
  10.             }       
  11.                   xmlWrite.WriteEndElement();                         
  12.  
  13.       }
  14.           xmlWrite.WriteEndElement();       
May 19 '10 #1

✓ answered by GaryTexmo

You're close.... it looks like your for loop is wrong. Try a google on C# for loops for syntax.

That middle term is a comparison, a boolean test.

2 1508
tlhintoq
3,525 Expert 2GB
"but it failed" doesn't leave much to go on.
Can you be a little more specific about your error etc.?
Otherwise you're just saying "My code is broke. Can someone debug it or write better code for me?" and I'm sure that's not your intention
May 19 '10 #2
GaryTexmo
1,501 Expert 1GB
You're close.... it looks like your for loop is wrong. Try a google on C# for loops for syntax.

That middle term is a comparison, a boolean test.
May 19 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: mish | last post by:
Please read and review my .Net Coding standards article at Informit.com (see url below). There are also other articles there about coding standards. Thanks Michelle ...
4
by: dotNetDave | last post by:
About three weeks ago I released the first .NET coding standards book titled "VSDN Tips & Tricks .NET Coding Standards". Here is what the famous author/ speaker Deborah Kurata says about it: ...
4
by: Karunakararao | last post by:
Hi all Please Convert the VB.Net to C# .NET Sub CustomPager(ByVal STCPagerGrid As Object) Dim intCtr As Integer Static intLastItem As Integer Static intCount As Integer Static intTotalPage,...
1
by: Kasper | last post by:
Hey dudes and dudies .. Im pretty new in this area. So I was wondering if anybody know a site on the internet that can give me a good start on coding C#.net ? Regards Kasper
1
by: BigAbility | last post by:
i'm learning about some controls of Vs.net 2005 . but finding some source code of 2005 is very difficult.. Where can i find Vs.net 2005 Source file or example ...?? i think upgrading...
2
by: Steven | last post by:
Hi. I have a dynamic ASPX page written in C# that I want to turn into a PDF file and store it for records. Please help, because I am not sure where to start. Thank you.
4
by: Praveen | last post by:
Hi All, Can anyone tell me where can I find a good aritcle on ASP.NET Coding Standards. I wanted only ASP.NET coding standards guide. Bye Praveen
3
by: Screaming Eagles 101 | last post by:
Hi, I have an Access MDB database with a Table1. From VBNET I would like to CREATE a NEW table, which is a copy of Table1, but not with the Data, only the definition. I would also like to have...
0
by: PerumalSamy | last post by:
Hi all, i am new to asp.net platform. I am using vb.net coding in asp.net. could you tell me how to generate crystal report in asp.net and to access in webpage and converting into pdf
0
by: tsarumugavel m | last post by:
hi, i am new in asp.net. my project specifiaction is caputre the image from webcam through asp.net coding. I want to capture the visitor photo. the web cam connect in the client system....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.