Expression

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I see in the docuementation that the System.TimeSpan is supported in the
CONVERT function for the DataColumn Expression property. How do I use it? I
tried everything and I get InvalidCastExceptions.

Thanks.
Mark
 
Please post some code so someone can help. Conversion syntax isn't
interchangeable between C# and VB.

--Mary
 
I'm using VB. I'm talking about the Expression property in the DataColumn. It
says it can convert a String to a TimeSpan in the documentation but I can't
figure out how its done.

Thanks
 
Mark,

Are you using this documentation?

http://msdn.microsoft.com/library/d...fsystemdatadatacolumnclassexpressiontopic.asp

Where is in


Example: myDataColumn.Expression="Convert(total, 'System.Int32')"

All conversions are valid with the following exceptions: Boolean can be
coerced to and from Byte, SByte, Int16, Int32, Int64, UInt16, UInt32,
UInt64, String and itself only. Char can be coerced to and from Int32,
UInt32, String, and itself only. DateTime can be coerced to and from String
and itself only. TimeSpan can be coerced to and from String and itself only.

I hope this helps,

Cor
 
Mark,

I have tested it and probably the same problem as you. I have placed your
question completely documented in another place as question and saved your
message. I hope that I can answer you soon.

If Mary will investigate it, I made this test

\\\
Dim dt As New DataTable
dt.Columns.Add("mystring", Gettype(System.String))
dt.Columns.Add("myDate", GetType(System.TimeSpan), _
"Convert(mystring, 'System.TimeSpan')")
dt.LoadDataRow(New Object() {"00:01:00"}, True)

'Error above, it is telling me that the conversion does not go
///

Cor
 
Try this:

Dim dt As New DataTable
dt.Columns.Add("mystring", GetType(System.String))
dt.Columns.Add("myDate", GetType(System.TimeSpan))

Dim newRow(1) As Object
newRow(0) = "Hello"
newRow(1) = TimeSpan.Parse("00:00:00")

dt.LoadDataRow(newRow, True)

--Mary
 
Mary,

That is no expression, an expression functions by instance as well direct
after that somebody commit the row as somebody changes a string in by
instance a windowsform datagrid. Your sample is a one time action.

For us is the status now that we think that it is a documentation bug,
because the code to do this is not direct in Net, however I did not get
enough replies to tell this.

Cor
 
If you think it's a doc bug, then please click the link on the bottom
of the page where it says "Send comments on this topic".

--Mary
 
Mary,

There are in my opinion not much people that use the web client for these
newsgroups.

So I am not and therefore there is no button, however I have placed this
problem somewhere else and wait first what will be the result of that.

Cor
 
Thanks for your feedback -- a bug is automatically created for you
when you click on the link. Your taking the time to improve the
documentation is much appreciated.

--Mary
 
Back
Top