[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Pulling sql server float as string and keep decimal places

Posted on 2006-11-21
6
Medium Priority
?
2,043 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
  • 3
  • 2
5 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

873 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