PC Review


Reply
Thread Tools Rate Thread

DataReader values and .ToString

 
 
Michel Vanderbeke
Guest
Posts: n/a
 
      24th Jul 2007
Hello,

In order to avoid errors, I have all my DataReader-fields converted with a
..ToString.
This in case some record could have Null-fields and an error would be
thrown.

This works fine, except for "money" fields in SQL-Server.
When I enter e.g. ? 2,50 and I read it back with a DataReader without
..ToString, I get the correct display.
However using .ToString, I get no valuta-sign and the value is multiplied by
10 000.

When trying to StringFormat the DataReader.ToString, I get a syntax error.

Can someone explain this to me an offer some help?

Many thanks and greetings,

Michel


 
Reply With Quote
 
 
 
 
William Vaughn
Guest
Posts: n/a
 
      24th Jul 2007
To avoid spending a lot of time coding, I send all of my DataReader output
to a DataTable via the Load method.
This deals with a litany of issues--one of which you describe here...

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant, Dad, Grandpa
Microsoft MVP
INETA Speaker
www.betav.com
www.betav.com/blog/billva
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

"Michel Vanderbeke" <(E-Mail Removed)> wrote in message
news:46a614b6$0$13858$(E-Mail Removed)...
> Hello,
>
> In order to avoid errors, I have all my DataReader-fields converted with a
> .ToString.
> This in case some record could have Null-fields and an error would be
> thrown.
>
> This works fine, except for "money" fields in SQL-Server.
> When I enter e.g. ? 2,50 and I read it back with a DataReader without
> .ToString, I get the correct display.
> However using .ToString, I get no valuta-sign and the value is multiplied
> by 10 000.
>
> When trying to StringFormat the DataReader.ToString, I get a syntax error.
>
> Can someone explain this to me an offer some help?
>
> Many thanks and greetings,
>
> Michel
>
>


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
calling .ToString() on Decimal values SOMETIMES appends a zero to end of string TS Microsoft C# .NET 3 3rd Mar 2012 03:40 PM
Extract values from DataReader Michel Vanderbeke Microsoft VB .NET 2 1st Jun 2007 08:06 PM
Why wont this datareader return any values? Miha Markic [MVP C#] Microsoft C# .NET 6 31st Oct 2005 02:35 PM
Re: Datareader and Null Values Scott M. Microsoft ADO .NET 1 4th Aug 2004 05:56 PM
DDL values with DataReader and stored procedures Rob Wire Microsoft ASP .NET 5 14th Aug 2003 10:50 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:52 AM.