I have a column in a data table that stores enum values and assigns a default
value:
Dim dc As New DataColumn("TestEnumField", GetType(DayOfWeek))
dc.DefaultValue = DayOfWeek.Thursday
When I try to serialize/deserialize dataset schema, I get the error below
during deserialization:
"System.ArgumentException: The DefaultValue for column TestEnumField is of
type System.DBNull, but the column is of type System.DayOfWeek."
I've tried reading/writing the XML using the dataset's built-in methods as
well as using the SOAP formatter, both with the same results.
When I look at the XML file that gets created during serialization, I can see
that the default value for the column is there. In the above case, it is
stored as an integer, 4. So, it's not DBNull but maybe there's some problem
during the deserialization process converting 4 into DayOfWeek type?
Is this a bug or am I doing something wrong?
Thanks. 9 2900
Peter,
We cannot see if you do something wrong. How do you do the serializing. Is
it like this sample on our website? http://www.vb-tips.com/default.aspx?...a-c891846eaf0b
Cor
"PeterWellington" <u19491@uwe> schreef in bericht news:5cfc2e14640cd@uwe... I have a column in a data table that stores enum values and assigns a default value:
Dim dc As New DataColumn("TestEnumField", GetType(DayOfWeek)) dc.DefaultValue = DayOfWeek.Thursday
When I try to serialize/deserialize dataset schema, I get the error below during deserialization:
"System.ArgumentException: The DefaultValue for column TestEnumField is of type System.DBNull, but the column is of type System.DayOfWeek."
I've tried reading/writing the XML using the dataset's built-in methods as well as using the SOAP formatter, both with the same results.
When I look at the XML file that gets created during serialization, I can see that the default value for the column is there. In the above case, it is stored as an integer, 4. So, it's not DBNull but maybe there's some problem during the deserialization process converting 4 into DayOfWeek type?
Is this a bug or am I doing something wrong?
Thanks.
Cor Ligthert [MVP] wrote: Peter,
We cannot see if you do something wrong. How do you do the serializing. Is it like this sample on our website?
http://www.vb-tips.com/default.aspx?...a-c891846eaf0b
Cor
I have a column in a data table that stores enum values and assigns a default [quoted text clipped - 22 lines] Thanks.
Yes, I've tried serializing/deserializing just as in the link you provided.
I'm pretty certain that's all correct in my code. For example, everything
serializes/deserializes error-free if I just take out the line of code where
I'm setting the default value for the DataColumn (i.e. commenting out "dc.
DefaultValue = DayOfWeek.Thursday").
Peter,
This code did run for me withouth any problem
\\\\
Dim ds As New DataSet
Dim dt As New DataTable
ds.Tables.Add(dt)
dt.Columns.Add("TestEnumField", GetType(DayOfWeek))
dt.LoadDataRow(New Object() {DayOfWeek.Thursday}, True)
Dim sw As New System.IO.StringWriter
ds.WriteXml(sw)
Dim mystring As String = sw.ToString
///
I hope this helps,
Cor
"PeterWellington" <u19491@uwe> schreef in bericht news:5cfc2e14640cd@uwe... I have a column in a data table that stores enum values and assigns a default value:
Dim dc As New DataColumn("TestEnumField", GetType(DayOfWeek)) dc.DefaultValue = DayOfWeek.Thursday
When I try to serialize/deserialize dataset schema, I get the error below during deserialization:
"System.ArgumentException: The DefaultValue for column TestEnumField is of type System.DBNull, but the column is of type System.DayOfWeek."
I've tried reading/writing the XML using the dataset's built-in methods as well as using the SOAP formatter, both with the same results.
When I look at the XML file that gets created during serialization, I can see that the default value for the column is there. In the above case, it is stored as an integer, 4. So, it's not DBNull but maybe there's some problem during the deserialization process converting 4 into DayOfWeek type?
Is this a bug or am I doing something wrong?
Thanks.
Cor Ligthert [MVP] wrote: Peter,
This code did run for me withouth any problem
\\\\ Dim ds As New DataSet Dim dt As New DataTable ds.Tables.Add(dt) dt.Columns.Add("TestEnumField", GetType(DayOfWeek)) dt.LoadDataRow(New Object() {DayOfWeek.Thursday}, True) Dim sw As New System.IO.StringWriter ds.WriteXml(sw) Dim mystring As String = sw.ToString ///
I hope this helps,
Cor
I have a column in a data table that stores enum values and assigns a default [quoted text clipped - 22 lines] Thanks.
The problem is not writing it to a stream or file or reading from the file,
per se. It's during deserialization when a dataset is created from the
schema that was written to the XML file during the serialization process.
For example:
originalDataSet.WriteXmlSchema(filePath)
Dim targetDataSet As New DataSet()
targetDataSet.ReadXmlSchema(filePath)
The exception occurs when the target dataset tries to read back the XML
schema. As I mentioned before, I could also use a SOAP formatter to
serialize/deserialize and I get the same error.
--
Message posted via DotNetMonster.com http://www.dotnetmonster.com/Uwe/For...neral/200603/1
Peter,
This code shows Thursday in a datagridview
Dim ds As New DataSet
Dim dt As New DataTable
ds.Tables.Add(dt)
dt.Columns.Add("TestEnumField", GetType(DayOfWeek))
dt.LoadDataRow(New Object() {DayOfWeek.Thursday}, True)
Dim sw As New System.IO.StringWriter
ds.WriteXml(sw)
Dim mystring As String = sw.ToString
Dim sr As New System.IO.StringReader(mystring)
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''
Dim ds2 As New DataSet
ds2.ReadXml(sr)
DataGridView1.DataSource = ds.Tables(0)
///
I can write the schema as well in this proces, that does not change the
result, however.
I hope this helps,
Cor
"PeterWellington via DotNetMonster.com" <u19491@uwe> schreef in bericht
news:5d06f4f0b1087@uwe... Cor Ligthert [MVP] wrote:Peter,
This code did run for me withouth any problem
\\\\ Dim ds As New DataSet Dim dt As New DataTable ds.Tables.Add(dt) dt.Columns.Add("TestEnumField", GetType(DayOfWeek)) dt.LoadDataRow(New Object() {DayOfWeek.Thursday}, True) Dim sw As New System.IO.StringWriter ds.WriteXml(sw) Dim mystring As String = sw.ToString ///
I hope this helps,
Cor
I have a column in a data table that stores enum values and assigns a default [quoted text clipped - 22 lines] Thanks.
The problem is not writing it to a stream or file or reading from the file, per se. It's during deserialization when a dataset is created from the schema that was written to the XML file during the serialization process. For example:
originalDataSet.WriteXmlSchema(filePath) Dim targetDataSet As New DataSet() targetDataSet.ReadXmlSchema(filePath)
The exception occurs when the target dataset tries to read back the XML schema. As I mentioned before, I could also use a SOAP formatter to serialize/deserialize and I get the same error.
-- Message posted via DotNetMonster.com http://www.dotnetmonster.com/Uwe/For...neral/200603/1
The problem occurs when you set a default value for the column. Here's a
simplified version of my code:
Dim ds As New DataSet("dsTest")
Dim dt As New DataTable("dtTest")
Dim dc As New DataColumn("TestEnumField", GetType(DayOfWeek))
dc.DefaultValue = DayOfWeek.Thursday
dt.Columns.Add(dc)
ds.Tables.Add(dt)
ds.WriteXmlSchema("C:\Temp\ds.xml")
Dim targetDS As New DataSet
targetDS.ReadXmlSchema("C:\Temp\ds.xml")
I think you'll find an error as well if you run the above code.
Cor Ligthert [MVP] wrote: Peter,
This code shows Thursday in a datagridview
Dim ds As New DataSet Dim dt As New DataTable ds.Tables.Add(dt) dt.Columns.Add("TestEnumField", GetType(DayOfWeek)) dt.LoadDataRow(New Object() {DayOfWeek.Thursday}, True) Dim sw As New System.IO.StringWriter ds.WriteXml(sw) Dim mystring As String = sw.ToString Dim sr As New System.IO.StringReader(mystring) ''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''' Dim ds2 As New DataSet ds2.ReadXml(sr) DataGridView1.DataSource = ds.Tables(0) ///
I can write the schema as well in this proces, that does not change the result, however.
I hope this helps,
Cor
Peter,
[quoted text clipped - 34 lines] schema. As I mentioned before, I could also use a SOAP formatter to serialize/deserialize and I get the same error.
--
Message posted via http://www.dotnetmonster.com
Peter,
You are right, even this won't work.
\\\
Dim ds As New DataSet
Dim dt As New DataTable
ds.Tables.Add(dt)
dt.Columns.Add("TestEnumField")
dt.Columns("TestEnumField").DataType = GetType(System.DayOfWeek)
dt.Columns(0).DefaultValue = DayOfWeek.Thursday
dt.Rows.Add(dt.NewRow)
ds.WriteXml("C:\test.xml", XmlWriteMode.WriteSchema)
Dim ds2 As New DataSet
ds2.ReadXml("C:\test.xml")
DataGridView1.DataSource = ds2.Tables(0)
///
He is converting the default value to 4 and won't than except it anymore.
I assume that it is a bug, I will see if (how) I can report this.
Cor
"PeterWellington via DotNetMonster.com" <u19491@uwe> schreef in bericht
news:5d0927fcaa160@uwe... The problem occurs when you set a default value for the column. Here's a simplified version of my code:
Dim ds As New DataSet("dsTest") Dim dt As New DataTable("dtTest")
Dim dc As New DataColumn("TestEnumField", GetType(DayOfWeek)) dc.DefaultValue = DayOfWeek.Thursday dt.Columns.Add(dc) ds.Tables.Add(dt)
ds.WriteXmlSchema("C:\Temp\ds.xml") Dim targetDS As New DataSet targetDS.ReadXmlSchema("C:\Temp\ds.xml")
I think you'll find an error as well if you run the above code.
Cor Ligthert [MVP] wrote:Peter,
This code shows Thursday in a datagridview
Dim ds As New DataSet Dim dt As New DataTable ds.Tables.Add(dt) dt.Columns.Add("TestEnumField", GetType(DayOfWeek)) dt.LoadDataRow(New Object() {DayOfWeek.Thursday}, True) Dim sw As New System.IO.StringWriter ds.WriteXml(sw) Dim mystring As String = sw.ToString Dim sr As New System.IO.StringReader(mystring) '''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''' Dim ds2 As New DataSet ds2.ReadXml(sr) DataGridView1.DataSource = ds.Tables(0) ///
I can write the schema as well in this proces, that does not change the result, however.
I hope this helps,
Cor
Peter, [quoted text clipped - 34 lines] schema. As I mentioned before, I could also use a SOAP formatter to serialize/deserialize and I get the same error.
-- Message posted via http://www.dotnetmonster.com
Peter,
I have reported it as Bug
Cor
"Cor Ligthert [MVP]" <no************@planet.nl> schreef in bericht
news:uU**************@TK2MSFTNGP10.phx.gbl... Peter,
You are right, even this won't work.
\\\ Dim ds As New DataSet Dim dt As New DataTable ds.Tables.Add(dt) dt.Columns.Add("TestEnumField") dt.Columns("TestEnumField").DataType = GetType(System.DayOfWeek) dt.Columns(0).DefaultValue = DayOfWeek.Thursday dt.Rows.Add(dt.NewRow) ds.WriteXml("C:\test.xml", XmlWriteMode.WriteSchema) Dim ds2 As New DataSet ds2.ReadXml("C:\test.xml") DataGridView1.DataSource = ds2.Tables(0) /// He is converting the default value to 4 and won't than except it anymore.
I assume that it is a bug, I will see if (how) I can report this.
Cor
"PeterWellington via DotNetMonster.com" <u19491@uwe> schreef in bericht news:5d0927fcaa160@uwe... The problem occurs when you set a default value for the column. Here's a simplified version of my code:
Dim ds As New DataSet("dsTest") Dim dt As New DataTable("dtTest")
Dim dc As New DataColumn("TestEnumField", GetType(DayOfWeek)) dc.DefaultValue = DayOfWeek.Thursday dt.Columns.Add(dc) ds.Tables.Add(dt)
ds.WriteXmlSchema("C:\Temp\ds.xml") Dim targetDS As New DataSet targetDS.ReadXmlSchema("C:\Temp\ds.xml")
I think you'll find an error as well if you run the above code.
Cor Ligthert [MVP] wrote:Peter,
This code shows Thursday in a datagridview
Dim ds As New DataSet Dim dt As New DataTable ds.Tables.Add(dt) dt.Columns.Add("TestEnumField", GetType(DayOfWeek)) dt.LoadDataRow(New Object() {DayOfWeek.Thursday}, True) Dim sw As New System.IO.StringWriter ds.WriteXml(sw) Dim mystring As String = sw.ToString Dim sr As New System.IO.StringReader(mystring) ''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''' Dim ds2 As New DataSet ds2.ReadXml(sr) DataGridView1.DataSource = ds.Tables(0) ///
I can write the schema as well in this proces, that does not change the result, however.
I hope this helps,
Cor
>Peter, > [quoted text clipped - 34 lines] schema. As I mentioned before, I could also use a SOAP formatter to serialize/deserialize and I get the same error.
-- Message posted via http://www.dotnetmonster.com
Thanks for looking into this. I appreciate it.
Cor Ligthert [MVP] wrote: Peter,
I have reported it as Bug
Cor
Peter, [quoted text clipped - 67 lines]> schema. As I mentioned before, I could also use a SOAP formatter to > serialize/deserialize and I get the same error.
--
Message posted via DotNetMonster.com http://www.dotnetmonster.com/Uwe/For...neral/200603/1 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bill C. |
last post by:
Hi,
I've got a simple console app that just reads an XML file into a DataSet
then prints out a description of each table in the DataSet, including
column names and row values for each column. ...
|
by: Usha Vas |
last post by:
Hi,
I had posted this question in donet.framework.adonet but thought it might
make more sense here, so I apologize for the duplicate post.
I have an XML schema with one of the elements (Sig)...
|
by: Pete Beech |
last post by:
Hi,
I've looked all over for any information about this, and either this is
a bug that I cannot find reported or I've misunderstood something.
Lets say, in the XML Designer in VS.NET 2003, you...
|
by: Peter Frost |
last post by:
Please help
I don't know if this is possible but what I would really like to do is
to use On Error Goto to capture the code that is being executed when
an error occurs.
Any help would be much...
|
by: ron |
last post by:
Hi,
I have class object that i serialize using the
System.Xml.Serialization class.
Intermittently the object is not getting serialized
correctly, using System.Xml.Serialization classes....
|
by: Matt Tinson |
last post by:
Hello
I have a datagrid with a datetimepicker column in it, which is bound to a dataset (MyDataset). The column in the dataset set that is mapped to the datetimepicker is called MyOrderDate and...
|
by: Jason L James |
last post by:
Hi all,
I recently wrote a vb.net app using oledb to
an access database. When I inserted new
rows in my datatable the identity column
was automatically created. This app used
an un-typed...
|
by: archana |
last post by:
Hi all,
I am having one dataset in which i am taking data from database.
Then in my application i am creating one new column into datatable of
that dataset and assigned one default value for...
|
by: =?Utf-8?B?dm96ZWxkcg==?= |
last post by:
I'm having an issue in deserializing an object from XML. I generated my XML
schema from my .NET dll using xsd.exe. I've used that schema in another
application. That application spits out XML based...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: SueHopson |
last post by:
Hi All,
I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...
| |