Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 908
  • Last Modified:

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"
            tblJB_Audit.Columns.Add(dcWeek)
        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.Rows.Add(workRow)


 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?

Thanks,
JMO9966
0
JMO9966
Asked:
JMO9966
1 Solution
 
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")

Regards,

Wayne
0
 
JMO9966Author Commented:
Thanks Wayne,

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

I appreciate your quick response.

JMO9966
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now