Use the C# decimal datatype rather than float - this is compatible with the
Sql Server money datatype.
One other point is that to get the best performance out of the sqldatareader
you should use the Getxxxx methods where possible - e.g.
decimal d = (decimal)mySqlDataReader["SomeField"];
decimal d = mySqlDataReader.GetDecimal(2);
Using this method you need to know the column ordinal rather than the name
but it's faster.
--
Steve Willcock, MCSD
http://www.willcockconsulting.com/
"Ghost" <da*********@hotmail.com> wrote in message
news:uY**************@TK2MSFTNGP10.phx.gbl...
Hello.
I have some problem to read Money Type Field from my database.
I do so:
I'm using SqlDataReader object to select some records and I have "float"
type variable to store result.
I write:
myFloatVar = (float)mySqlDataReader["SomeField"];
When this line executed the cast exception occurs.
The same problem I have when I'm try to assign record value to "char" type
variable.
myCharVar = (char)mySqlDataReader["SomeField"];
How do I these assignments?