VB.Net - WriteXMLSchema fails on my DataTabe ?  Cannot serialize the DataTable. DataTable name is not set.

Posted on 2007-08-08
Last Modified: 2008-01-09
I've used this same code for generating a schema file to use for Crystal Reporting but I've always used DataSet\DataTable.

In this case I simply have a DataTable.

  Private tblJB_Audit As New DataTable()

        Dim cols As DataColumnCollection = tblJB_Audit.Columns

        If cols.Contains("Week") = False Then
            Dim dcWeek As New DataColumn
            dcWeek.DataType = System.Type.GetType("System.String")
            dcWeek.AllowDBNull = True
            dcWeek.ColumnName = "Week"
        End If

 Dim workRow As DataRow = tblJB_Audit.NewRow()
                    'Dim strError As String
                    'strError = "Inventory shortage."

                    workRow("week") = strDate
                    workRow("OnHandQty") = OnHandQty
                    workRow("Supply_Qty") = SupplyQty
                    workRow("Part") = PartNo
                    workRow("Demand_Qty") = Qty
                    workRow("PAB") = AvailableQty


 tblJB_Audit.WriteXmlSchema(Application.ExecutablePath & "Neill MRP View.xsd")

ERROR = Cannot serialize the DataTable. DataTable name is not set.

Not sure how to fix this error.  Can you give me a hand?

Question by:JMO9966
    LVL 46

    Accepted Solution

    Hi JMO9966,

    The error pretty much gives the answer....

         ERROR = Cannot serialize the DataTable. DataTable name is not set.

    So, give the datatable a name....

        Private tblJB_Audit As New DataTable("TableName")



    Author Comment

    Thanks Wayne,

    I usually use DataSets and Fill with sql statements instead of creating DataTables.

    I appreciate your quick response.


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Article by: jpaulino
    XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now