Hi,
I'm having some trouble with my asp.net page and my sql database. What I'm trying to do is allow the user to upload an number to the database, the number is a money amount like 2.00 (£2.00) or 20.00(£20.00). I've tried using money and smallmoney datatypes but the numbers usually end up looking like this in the database...
I enter 2.00 and in the database it looks like 2.00000, and even if I enter the information directly into the database I get the same results. I'm not going to be using big numbers with lots of decimal places like this 1000,000,0000. Can anyone help me? All I want is to know what to set the value to on my aspx page and what setting to set the field to in my database, I'd just like two pound to appear as 2.00. any help would be great.
I'm using Microsoft Visual Web Developer 2005 Express Edition and Microsoft SQL Server 2005 if that helps.
I have a special need in a view for a money column to look like money and still be a money datatype. So I need it to look like $100.00 (prefered) or 100.00(can make work). If I convert like this '$' + CONVERT (NVARCHAR(12), dbo.tblpayments.Amount, 1) it is now a nvarchar and will not work for me. How can I cast so it is still money? by default the entries look like 100.0000. They must remain a money datatype.
Please i need to display the money column in DataBase in an asp.net page but i get something like this 786.0000 how can i format it so that i get something like 786.00 Thanx
Hi everybody.Here's my Product tableID int,Title nvarchar(50),Price moneyHow can I get value from price field like thisIF PRICE is 12,000.00 it will display 12,000IF PRICE is 12,234.34 it will display 12,234.34Thanks very much...I am a beginner. Sorry for foolish question
Argggg....Please help.I need to store money in SQL Server.I am using C# and a stored procedure to insert.How do you accomplish this? Specifically what datatype should the money variable be in C# during the insert? It's initial value is a string as it is entered from a text field.I have been trying for over an hour now to simply insert money into SQL Server using C# and have it stored as a money type!Thanks
hello everyone...,i have problem in money format...i have moneytable is containning: userid money A 20000,0000 B 40000,0000userid type varchar(50)money type money i have store procedure like this:ALTER PROCEDURE [dbo].[paid]( @userid AS varchar(50), @cost AS money, @message as int="1" output)ASbegin transactiondeclare @money as money select @money = moneyfrom moneytablewhere userid=@useridif (@money > @cost)beginset @money = @money - @costUPDATE moneytable SET money = @money WHERE userid=@useridset @message ='1'endelsebeginset @message = '2' endCOMMIT TRANSACTION when i execute this procedure. i insert value to userid Acost 100,0000 it can not decrease, because cost 100,0000 is same with 1000000, why is like that?i want cost 100,0000 is same with 100. how can i do that? thx...
I have a field in database money. When I enter value for it the amount entered is for example 20.000. How can I compare this value with noraml vaules i.e. like 20 in my search engine. Will I need to convert it to varchar and then compare it or is there some other way. Also if I need to convert it to varchar, how can I do it?
Here in Belgium, we work with a comma as decimal seperator, also in all the web apps... I've tried to update a money table on the sql with following statement update parts set article = '" & art & "' and price= cast(" & p & " as decimal(5,2)) where supid=202 in this example p is a variable and contains figures like 5,7 This statement always give following error Incorrect syntax near the keyword 'as' does some have an idea how to fix this one ?
How do you keep or round a money datatype to use only 2 decimal places? I have an instance where I am multiplying a money with a decimal datatype. The decimal has up to 8 decimal places. This is causing the money datattype to extend to 4 decimal places. This makes for problems when I am comparing 2 values.
ex.) IF 14.88 >= 14.8821
99% of the time this does not happen, but is causing problems. Does anyone have any suggestions?
From query analyzer how can I change the field datatype from money to varchar? Alter table tablenaame alter column columnname varchar(30)--Is not working.
Hi all. Is there a way in SQL to convert the integer to currency format? just for example.... 4000 convert to 4,000 1312500 convert to 1,312,500 30000 convert to 30,000
Most of you will say "Do it in your front end"... but the problem is I don't know how to do it in my Report(Business Intelligence Project). If anyone of you knows, tell me please... Thanks. :)
Do you usually use the money or smallmoney datatype for US dollars in a table, or do you use a decimal datatype, and if so which. Any opinions on the advantages and disadvantages of each?
If you use money or smallmoney, do you usually add a constraint to make sure the value is even to the penny (no $24.3487 type amounts)?
I'm looking for a way to "secure" a column of MONEY values. The idea is to hide the value without resorting to actual SQL encryption services that would require converting the MONEY to a VARBINARY. In short, I want to keep the column type as MONEY, but I want to scramble the value, so its still a valid MONEY type.
The goal is to have a pair of UDF's SCRAMBLE() and UNSCRAMBLE() that work on MONEY.
I've done some searching, but have not found anything along this topic.
I have a Windows 2003 server, with SQL 2005. How do i change the culture/regional options for the database as on my local test machine (which seems to be exactly the same in terms of windows regional settings and SQL server settings) the currenency fields show with a £ signs as expected, however on my production box they are $. I know this should be simple but its the night before a deadline and my brain is screwed. Please help!!
I use asp.net 2.0 and sql server 2005 for a web site (and Microsoft enterprise library).When I run aplication at local there is no problem but at the server I take this error:Disallowed implicit conversion from data type varchar to data type money, table 'dbname.dbo.shopProducts', column 'productPrice'. Use the CONVERT function to run this query.productPrice coloumn format is money. It was working correctly my old server but now it crashed.How can I solve this problem? And why it isn't work same configuration? My code:decimal productPrice;Database db = DatabaseFactory.CreateDatabase("connection");string sqlCommand = "update shopProducts set ......................,productPrice='" + productPrice.ToString().Replace(",", ".") + "',..................... where productID=" + productID + " ";db.ExecuteNonQuery(CommandType.Text, sqlCommand)
Hi there,I have a table products with product_price money(8) field. I have a stored procedure,CREATE procedure p_dat_update_product( @product_id int, @product_price decimal) asset nocount ondeclare @msg varchar(255) -- error message holder-- remove any leading/trailing spaces from parameters select @product_id = ltrim(rtrim(@product_id)) select @product_price = ltrim(rtrim(@product_price))-- turn [nullable] empty string parameters into NULLs if (@product_id = N'') select @product_id = null if (@product_price = N'') select @product_price = null-- start the validation if @product_id is null begin select @msg = 'The value for variable p_dat_update_product.@product_id cannot be null!' goto ErrHandler end-- execute the query if exists (select 'x' from product where product_id = @product_id) begin update dbo.product set product_price = @product_price where product_id = @product_id end if (@@ERROR <> 0) goto ErrhandlerreturnErrHandler: raiserror 30001 @msg returnGO And a class function public void Edit_Product(string product_id,string product_price) { decimal dec_product_price = decimal.Parse(product_price); SqlDataServ oMisDb = new SqlDataServ("LocalSuppliers"); oMisDb.AddParameter("@product_id", product_id); oMisDb.AddParameter("@product_price", dec_product_price.ToString()); oMisDb.ExecuteCmd("p_dat_update_product"); }But i keep getting this error,Error converting data type nvarchar to numericoMisDb.ExecuteCmd("p_dat_update_product"); I do not know what to do and solve this. Is there something that i have done wrong.thanks in advance. PS: still learning aspx and ms sql
have a SQL server table with a vairbale unitCost of type money and via a stored procedure I am trying to update it. Through asp I capture the value as a string and then ATTEMPT to convert it into a variable of type money before executing the stored procedure as follows.
SqlParameter parameterUnitCost= new SqlParameter("@unitCost", SqlDbType.Money,8); parameterUnitCost.Value = unitCost; myCommand.Parameters.Add(parameterUnitCost);
This gives me an input string error. On the other hand if I change that line to the following, the page works flawlessley:
SqlParameter parameterUnitCost= new SqlParameter("@unitCost", SqlDbType.Money,8); parameterUnitCost.Value = 25.45; myCommand.Parameters.Add(parameterUnitCost);
i'm get some strange behaviour with the money and float type. with a calculator divide 70 by 47 and multiply by 40 (70 / 47 * 40) and you get 59.5744 (rounded to nearest 4 decimal places). now try this in query analyser with the 70 as a money type and the result as a float:
Could someone explain to me what the best practices are for using these three data types? (i.e. when to use them). I thought this would be a simple answer to find, but after looking through books on line, and this forum, I have still not found the answer. Can anyone help?
I want to print in an error message a money value but have to convert it to a varchar first. I do not have any clue how to do this. Could someone help me out?
SELECT @iError = @@error, @iRowCount = @@rowcount IF(@iError <> 0 OR @iRowCount <> 1) BEGIN CONVERT(@dValue, @cValue) set @cError = 'Error attempting to insert new record. Product : ' + @cProduct + ' Sub-account : ' + @cSubAccount + ' Cost : $' + @cValue RAISERROR(@cError, 16, 1) END
Hi, I'm working on a DB and I'm trying to write some select statements that will display an employee's pay using the CAST and CONVERT functions. However, I can never seem to get commas inserted into the results please help. Here's the SELECT statements, where am I going wrong?
SELECT '$' + CAST(CONVERT(MONEY, SUM(PROJECT_BUDGET/1.00), 1) AS VARCHAR) AS 'Total Budget' FROM PROJECT;