Showing posts with label converting. Show all posts
Showing posts with label converting. Show all posts

Friday, March 30, 2012

problem with CAST and CONVERT in SQL Server2000 converting decimal places from 4 to 2

All of my currency columns are only storing 2 decimal places when I insert into the database but when I pull out the data with a SELECT statement, I always get 4 decimal places instead of the 2 that were inserted.

For example:

Database Price SELECT statement Price

100.56 100.5600

I have tried to use the CAST and/or CONVERT commands but I cannot get the output to come out as 100.56. Has anyone had a similar problem?

Thanks

Paradise [ip]

Look at the STR() function in Books Online.

STR(FloatExpression,LengthOverall,PlacesToRightOfDecimal)

|||Usually this type of formatting is done on the client side. You can use any of the string.format functions.|||You application is having a precision problem, it happens in SQL Server, there are two solutions a third party driver that on the TDS(Tabular Data Stream) level correct it or do it the cheap and free way use Decimal or Numeric instead of money and your problems will go away. Numeric is bigger than money but you will not get that problem. Hope this helps.|||I have tried to use the decimal datatype convert but it is rounding up or down and I am trying to show an amount, i.e. price. I just need something that will allow me to show the value as it exists in the database. When I view the data in the table, I only see the two decimal places.|||

Try the format in these links. Hope this helps


http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconformattingnumericdataforspecificculture.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcustomnumericformatstringsoutputexample.asp

Tuesday, March 20, 2012

Problem while trying to login to admin

Server Error in '/' Application.

Syntax error converting character string to smalldatetime data type.

Description:Anunhandled exception occurred during the execution of the current webrequest. Please review the stack trace for more information about theerror and where it originated in the code.

Exception Details:System.Data.SqlClient.SqlException: Syntax error converting character string to smalldatetime data type.

Source Error:

An unhandled exception was generated during the execution of thecurrent web request. Information regarding the origin and location ofthe exception can be identified using the exception stack trace below.


Stack Trace:

[SqlException: Syntax error converting character string to smalldatetime data type.]
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +180
LEInternational.admin.login.btnLogin_Click(Object sender, EventArgs e) in W:\le-international\admin\login.aspx.cs:87
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33

System.Web.UI.Page.ProcessRequestMain() +1292



Version Information: Microsoft .NET Framework Version:1.1.4322.2407; ASP.NET Version:1.1.4322.2407

Try to identify the T-SQL/stored proc that is causing this erros and post it here.

|||

I agree, it would help to see some code... It may be that you have some bad data in your database that won't convert to a smalldatetime. But it's impossible to know if the problem is in the stored procedure or your data without seeing the SP

Monday, March 12, 2012

Problem while converting pdf document to Word.

Hi,
I have a pdf document which is generated from MS SQL Reporting Services.
I am unable to convert the pdf document(which was generated from MS SQL
Reporting Services) To a WORD document USINg SOme tools which i downloaded
from Internet.
The PDF document i generated using Reporting services,has just some static
text.
any idea?
thanks for your reply,
regards
praveenThis problem comes only with pdfs which are generated using MS SQL reporting
Services.
"praveen79" wrote:
> Hi,
> I have a pdf document which is generated from MS SQL Reporting Services.
> I am unable to convert the pdf document(which was generated from MS SQL
> Reporting Services) To a WORD document USINg SOme tools which i downloaded
> from Internet.
> The PDF document i generated using Reporting services,has just some static
> text.
> any idea?
> thanks for your reply,
> regards
> praveen