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

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?

Who is Participating?
Wayne Taylor (webtubbs)Commented:
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")


JMO9966Author Commented:
Thanks Wayne,

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

I appreciate your quick response.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.