Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 17th, 2003, 08:43 AM
Registered User
 
Join Date: Nov 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default convert

i am doing a online shopping cart.

I have 2 tables here.
In table tblOrders, i change the datatype of the columns( SubTotal,TaxTotal and GrandTotal) and also in OrderItems table(cost) to money.
Then I received this error:



Disallowed implicit conversion from data type nvarchar to data type money, table 'Flower.dbo.OrderDetails', column 'SubTotal'. Use the CONVERT function to run this query. Disallowed implicit conversion from data type nvarchar to data type money, table 'Flower.dbo.OrderDetails', column 'TaxTotal'. Use the CONVERT function to run this query. Disallowed implicit conversion from data type nvarchar to data type money, table 'Flower.dbo.OrderDetails', column 'GrandTotal'. Use the CONVERT function to run this query.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Disallowed implicit conversion from data type nvarchar to data type money, table 'Flower.dbo.OrderDetails', column 'SubTotal'. Use the CONVERT function to run this query. Disallowed implicit conversion from data type nvarchar to data type money, table 'Flower.dbo.OrderDetails', column 'TaxTotal'. Use the CONVERT function to run this query. Disallowed implicit conversion from data type nvarchar to data type money, table 'Flower.dbo.OrderDetails', column 'GrandTotal'. Use the CONVERT function to run this query.


my question here:
how to convert the varchar to money by using query language?
 
Old November 17th, 2003, 10:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

This is not a technical forum- this is a feeback forum. You need to ask this question in a technical forum. I would move it for you, however you don't mention what database technology your using.



Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee
 
Old November 17th, 2003, 07:09 PM
Registered User
 
Join Date: Nov 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Practically all of the posts in this forum are technical.

If this forum is actually supposed to be feedback (whatever that is), then why not let it be technical? It seems that's what most people want.






 
Old November 17th, 2003, 11:51 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alyeng2000
Default

hi Hal Levy could you explain some, what is your meant by technical forum,feed back forum????
and you will move ngang'message to a technical forum



Ahmed Ali
Software Developer
 
Old November 18th, 2003, 01:56 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Guys,

I would request "alyeng2000" and "cs001" to please put an end to discussing on "Hal Levy's" post and try helping "ngang" solving his problem.

Thanks for your understanding.


-Vijay G
 
Old November 18th, 2003, 07:39 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:
In table tblOrders, i change the datatype of the columns( SubTotal,TaxTotal and GrandTotal) and also in OrderItems table(cost) to money
How?

Please go into a bit more detail (e.g. post the relevant code if you are executing some query) on what you are doing that gives you this error.

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old November 21st, 2003, 06:01 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

I hope this helps
CAST and CONVERT
Explicitly converts an expression of one data type to another. CAST and CONVERT provide similar functionality.

Syntax
Using CAST:

CAST ( expression AS data_type )

Using CONVERT:

CONVERT ( data_type [ ( length ) ] , expression [ , style ] )

Arguments
expression

Is any valid Microsoft® SQL Server™ expression. For more information, see Expressions.

data_type

Is the target system-supplied data type, including bigint and sql_variant. User-defined data types cannot be used. For more information about available data types, see Data Types.

length

Is an optional parameter of nchar, nvarchar, char, varchar, binary, or varbinary data types.

style

Is the style of date format used to convert datetime or smalldatetime data to character data (nchar, nvarchar, char, varchar, nchar, or nvarchar data types), or the string format when converting float, real, money, or smallmoney data to character data (nchar, nvarchar, char, varchar, nchar, or nvarchar data types).

SQL Server supports the date format in Arabic style, using Kuwaiti algorithm.

In the table, the two columns on the left represent the style values for datetime or smalldatetime conversion to character data. Add 100 to a style value to get a four-place year that includes the century (yyyy).



 
Old November 21st, 2003, 06:03 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

SELECT CONVERT(VARCHAR, CAST(123456.12 AS MONEY), 1)










Similar Threads
Thread Thread Starter Forum Replies Last Post
Help to convert c++ to c# happy_face C# 2 November 9th, 2007 10:56 PM
how to convert ???? bobolov Classic ASP Basics 2 June 15th, 2006 12:58 PM
CONVERT Adam H-W SQL Server ASP 5 September 24th, 2004 10:53 AM
Convert to a number ticktack Classic ASP Basics 4 February 9th, 2004 05:31 AM
convert ngang SQL Language 1 November 21st, 2003 05:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.