[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Pulling sql server float as string and keep decimal places

Posted on 2006-11-21
6
Medium Priority
?
2,033 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 1000 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

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

656 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