[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

04/21/2006 at 11:34AM PDT, ID: 21822684
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

Problem creating an XML file form a datatable

Asked by ajaac in Microsoft Visual Basic.Net

Tags: xmltextwriter

I'm missing something that I've spent the last few hours stuck on, hopefully someone can point me in the right direction.

I'm trying to create an xml document to be opened later by excel.
I can do this with dataset.writexml, but I only want one table written to the xml file.

I get an error on this line.
           rootElement.AppendChild(rowElement)
The error is Object reference not set to an instance of an object.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

I suspect the problem to be with this line.
        Dim rootElement As XmlElement = doc.DocumentElement
I just don't see what i need to do to get this to work.

Code

        Dim dsBrowse As DataSet = CType(Session("dsBrowse"), DataSet)
        Dim strFilename As String
        strFilename = "C:\Customers2.xml"
        Dim dt As New DataTable
        Dim row As DataRow
        Dim rowElement As XmlElement
        dt = dsBrowse.Tables("tblContact")
        Dim doc As XmlDocument = New XmlDocument
        Dim xw As XmlTextWriter = New XmlTextWriter(strFilename, System.Text.Encoding.UTF8)
        Dim rootElement As XmlElement = doc.DocumentElement()
        Dim i As Integer, cnt As Long
        Dim colElement(dt.Columns.Count) As XmlElement
        xw.WriteProcessingInstruction("xml", "version='1.0'")
        xw.WriteProcessingInstruction("mso-application", "progid='Excel.Sheet'")
        For Each row In dt.Rows
            rowElement = doc.CreateElement("Table")
            For i = 0 To dt.Columns.Count - 1
                colElement(i) = doc.CreateElement(dt.Columns(i).Caption)
                colElement(i).InnerText = row(i).ToString()
                rowElement.AppendChild(colElement(i))
            Next i
            rootElement.AppendChild(rowElement)
        Next
        doc.WriteTo(xw)
        xw.Close()
[+][-]04/21/06 12:10 PM, ID: 16510578

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/21/06 12:30 PM, ID: 16510829

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/21/06 12:32 PM, ID: 16510849

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/21/06 12:39 PM, ID: 16510927

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/21/06 12:44 PM, ID: 16510989

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/21/06 12:51 PM, ID: 16511079

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/21/06 01:00 PM, ID: 16511189

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/24/06 04:56 AM, ID: 16524120

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual Basic.Net
Tags: xmltextwriter
Sign Up Now!
Solution Provided By: TheLearnedOne
Participating Experts: 1
Solution Grade: A
 
 
[+][-]04/24/06 04:56 AM, ID: 16524128

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/24/06 04:58 AM, ID: 16524166

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/16/06 04:04 AM, ID: 16689382

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]05/25/06 04:06 AM, ID: 16759653

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]05/29/06 12:12 AM, ID: 16782422

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91 - Hierarchy