Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Expression

84 views
Skip to first unread message

Mary Chipman [MSFT]

unread,
Oct 6, 2005, 2:34:32 PM10/6/05
to
Please post some code so someone can help. Conversion syntax isn't
interchangeable between C# and VB.

--Mary

On Wed, 5 Oct 2005 11:50:04 -0700, "Mark"
<Ma...@discussions.microsoft.com> wrote:

>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

Mark

unread,
Oct 6, 2005, 3:29:52 PM10/6/05
to
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

Cor Ligthert [MVP]

unread,
Oct 6, 2005, 4:24:02 PM10/6/05
to
Mark,

Are you using this documentation?

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatacolumnclassexpressiontopic.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" <Ma...@discussions.microsoft.com> schreef in bericht
news:3A89010D-370F-4673...@microsoft.com...

Mark

unread,
Oct 6, 2005, 5:15:03 PM10/6/05
to
Yes that's what I'm reading.
But how do I use the TimeSpan???

Cor Ligthert [MVP]

unread,
Oct 7, 2005, 4:34:23 AM10/7/05
to
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


Mary Chipman [MSFT]

unread,
Oct 10, 2005, 5:10:19 PM10/10/05
to
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

Cor Ligthert [MVP]

unread,
Oct 11, 2005, 2:32:34 AM10/11/05
to
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

"Mary Chipman [MSFT]" <mc...@online.microsoft.com> schreef in bericht
news:q3mlk1hshkhi7igvf...@4ax.com...

Mary Chipman [MSFT]

unread,
Oct 12, 2005, 4:04:48 PM10/12/05
to
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

On Tue, 11 Oct 2005 08:32:34 +0200, "Cor Ligthert [MVP]"

Cor Ligthert [MVP]

unread,
Oct 12, 2005, 4:32:16 PM10/12/05
to
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


Mary Chipman [MSFT]

unread,
Oct 18, 2005, 9:27:43 AM10/18/05
to
Sorry for not being clear. I was not referring to the web client for
the newsgroups, but to the help topic posted earlier in this thread,
which may contain a doc bug:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatacolumnclassexpressiontopic.asp

--Mary

Cor Ligthert [MVP]

unread,
Oct 19, 2005, 3:13:29 AM10/19/05
to
Mary,

I have sent it, there is a cc to you, good work in my idea from you.

Cor


Mary Chipman [MSFT]

unread,
Oct 19, 2005, 3:29:15 PM10/19/05
to
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

0 new messages