Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: How to use the convert function to convert Datatype while using the query??


Message #1 by "kaps" <stradbroke@c...> on Thu, 7 Mar 2002 08:25:23
helo,



I got a little question about this Convert Function to convert String to 

Money datatype.



"Price" is a "Money" datatype in db and when i try to add/update the 

record it throws an error and ask me to use the Convert function!



I found out about that as well but the trouble is that if i use the same 

query in Query Analyser of SQL Server it works well but something goes 

wrong when i use it with ASP.



The Query i have used for the add is:



insert into Horses(fk_RaceID,TabNum,Barrier,Ranking,Chance,Price,Presort) 

values('" & RaceID & "', '" & TabNum & "','" & Barrier & "','" & Ranking 

& "','" & Chance & "',(Select CONVERT(Money,Price)),'" & Presort & "')



For adding the data for the same table gives me error:



"Only scalar expressions are allowed"





Query for Updating Record is:



update Horses set TabNum = '" & TabNum & "', Barrier = '" & Barrier & "', 

Ranking = '" & Ranking & "', Chance = '" & Chance & "', Price = (Select 

CONVERT(Money,Price)), Presort = '" & Presort & "' where HorseID = '" & 

HorseID & "' 





Can anyone help me please?



Your reply will be appreciated!!



Regards.

  Return to Index