Wrox Programmer Forums
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language 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 18th, 2003, 12:36 AM
Registered User
 
Join Date: Nov 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default convert

HAI:
I am now ddeveloping a shopping cart.
my database is SQL 2000.

In table OrderdDetails, 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.

Source Error:


Line 11:
Line 12: Sub btnCheckout_Click(sender As Object, e As System.EventArgs)
Line 13: WriteToDB1.Save()
Line 14: End Sub
Line 15:


Source File: d:\inetpub\wwwroot\Fragrance\cart\order.aspx Line: 13
__________________________________________________ __________________

i realize that it is some thing do with the CONVERT function Query in SQL Server.
So i try it out by right click the tblOrders and open the table by query.
Then i type this query statement:

SELECT

SubTotal
TaxTotal
GrandTotal

CONVERT
(varchar(50)
convert(money(8)))

FROM
OrderDetails


But sad to say that until now i have't get the right query yet.

Some syntax error, such as inccorect syntax near'GrandTotal'....

Any suggestion on how to solve this problem?
may be has other ways ?
Please help!


 
Old November 21st, 2003, 05:47 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

This article from MS may help clear up somethings
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).








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 Server 2000 7 November 21st, 2003 06:03 PM





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