Solved

Pulling sql server float as string and keep decimal places

Posted on 2006-11-21
6
2,025 Views
Last Modified: 2008-01-09
Hi Experts,
   I have a sqlserver 2000 table that stores several float fields, in vb.net 03' I am pulling these values via sqldatareader.  My question is how can preserve the value stored as is from the table.  Everyway I have tried, truncates decimals on whole numbers.  I would like to pull these values as is with no rounding or truncation. eg if 75.00 is stored in the db I want to pull 75.00 not 75.  I know I can manually cast these values as varchar in sql to get the values or or do codebehind to handle it, but I'm sure there is a way that I can to pull it from the sqldatareader functions as is.  Thanks in advance ....

oh here is an example just in case:

If qdb.queryDbase(sqlState, sqlConn, reader, False, errText, pnErr) Then
            If reader.HasRows Then
                If reader.Read Then
                    ReDim Preserve cspppdInfo(0)
                    cspppdInfo(0) = reader.GetValue(0)
                End If
            Else
                pnNoRecords.Visible = True
                pnContainer.Visible = False
            End If
End if
0
Comment
Question by:dbedoo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17995043
The only way that I can think that the decimals get truncated are if the field is treated as an integer, instead of a float.

Bob
0
 
LVL 1

Author Comment

by:dbedoo
ID: 17995146
No its treated as a float but VB just doesn't show the decimal point on whole numbers when pulling this way.    I messed it with it for awhile yesterday and couldn't find a way so I ended up using vb code to handle it.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
ID: 17995163
What happens if you do this?

cspppdInfo(0) = reader("field1").ToString()

Bob
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 18131587
Delete/No Refund

Bob
0
 
LVL 1

Author Comment

by:dbedoo
ID: 18188616
sorry for the delay ;-)  thanks
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question