Showing posts with label base. Show all posts
Showing posts with label base. Show all posts

Friday, March 9, 2012

problems with float numbers

hi

im using a stored procedure to insert float numbers in a data base...the parameter i send to the stored procedure is a float but every time i use it, it inserts a number with a lot of extra numbers i mean if i try to insert 5.3 it inserts 5.30000019073486 any idea why this is happening?

thak you

Himarcelocr2,

Have you done any sort of calculation before add/update or during you retrieve the float value?

Anyway, try this before you update your float value:

Math.Round(yourFloatValue, numberOfDecimal)

Hope this is help

|||

What is the datatype of the column in the table that will have these values? If you only need 3 digits after the decimal use the decimal datatype and set the precision to 3. You can do this in the column properties under design view. Enterprise Mgr -> Right click on the table -> Design View.

|||

hi

thank you to both of you

i tried with the math.round, but it converts the numbers to integers, and i need the numbers to be float numbers...

i cant change the type in the sqlserver because i need it to be a float number

is there a way to show only 3 or 4 numbers after the ","?

thank you

|||

Hello,

You should let is save like that only and should use round(SQL function-round(fieldname,4)) in Stored Procedures where you retrive data.

|||

Hi,

The Float datatype in both SQL Server and .NET framework is a floating point value. It is not accurate but an approximate value. This is defined by way that float is stored in memory.

However, if you need an accurate value, try to use Decimal instead in both SQL Server and .NET framework.

HTH. If this does not answer your question, please feel free to mark the post as Not Answered and reply. Thank you!

Wednesday, March 7, 2012

Problems with connecting to sql server table

Hello, I have SQL server installed on my stand alone PC. In summary the problem I am having is connecting to the data base through my web form, when the web application runs. In more detail, here is the problem:

I am using the data form wizard to display Data from a NorthWind data table in SQL server. I create a data set name dsCustomers, and then through the wizard specify (local) as the server name. I also select that I would like to use Windows NT integrated security to log on to the server.

I then continuue through the server and the Wizard indicates that I can connect to the NorthWind Data Base. I am able to view the data table to choose "Customers". I continue with the remaining information in the wizard and finish the process. Now when I run the program/(HTML web form) my web page comes up with a button I have labeled "load". When I press this button I want my data to be displayed in my web form.

The problem is that when I press the "load" button, I get an error page saying the following:

login failed for user 'BVCOMPUTER\ASPNET'

I traced into the code and the failure occurs when the internal code is called: this.oleDbConnection1.open()

Note that basically I am trying to run the sample code in Kalanis book for MCP 70-315. This is on page 358 of his book for the program StepByStep5_11.aspx.

I would appreciate someones help as I am stuck on this problem.

Sincerely,

William

You need to add the BVCOMPUTER\ASPNET Windows user to SQL Server as a user with rights to the database involved, or use SQL Server security and pass in a username and password.|||

Hello thanks, but please I still need help!! So you say I need to add the BVCOMPUTER\ASPNET Windows user to SQL server as a user with rights to the database involved.How do I do this??

Just fyi, it might not matter but just to let you know, currently when I do queries in Query Analyzer, the Query Dialog box list the following string:

BVCOMPUTER.master.BVCOMPUTER\smokey

|||

If you have Enterprise Manager, expand out the Security folder for the correct server, click on Logins, and then right click, and select New Login from the context menu.

Click on hte button next to theName textbox and pick the ASPNET user from the current machine (presuming the Web server and Database server are the same machine).