JMO9966
asked on
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("Syste m.String")
dcWeek.AllowDBNull = True
dcWeek.ColumnName = "Week"
tblJB_Audit.Columns.Add(dc 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.Rows.Add(workR ow)
tblJB_Audit.WriteXmlSchema (Applicati on.Executa blePath & "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
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("Syste
dcWeek.AllowDBNull = True
dcWeek.ColumnName = "Week"
tblJB_Audit.Columns.Add(dc
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(workR
tblJB_Audit.WriteXmlSchema
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I usually use DataSets and Fill with sql statements instead of creating DataTables.
I appreciate your quick response.
JMO9966