Author |
Topic  |
|
redbrad0
Advanced Member
    
USA
3725 Posts |
Posted - 05 May 2001 : 15:36:27
|
can anyone tell me why this is not working? i thought that 39.99 is in the format fto be inserted into a money field
Insert Into ExhibitParts_Orders (OR_Customer_ID, OR_Date_Ordered, OR_Product_Total, OR_Shipping_N_Handling_Total, OR_Taxes_Total, OR_Products_Ordered) VALUES ('1', '5/5/2001', '39.99', '1.11', '1.11', '4-26-39.99|') Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC SQL Server Driver][SQL Server]Disallowed implicit conversion from data type varchar to data type money, table 'freeaspcodesql.dbo.ExhibitParts_Orders', column 'OR_Product_Total'. Use the CONVERT function to run this query.
/exhibitparts/store/checkout.asp, line 37
Brad |
|
HuwR
Forum Admin
    
United Kingdom
20595 Posts |
Posted - 05 May 2001 : 15:50:23
|
money is a numeric value and therfore should not be siurrounded by ''
|
 |
|
Doug G
Support Moderator
    
USA
6493 Posts |
Posted - 05 May 2001 : 17:53:40
|
quote: '4-26-39.99|'
And what's the other stuff in the field? Shouldn't it just be 39.99 ?
====== Doug G ====== |
 |
|
redbrad0
Advanced Member
    
USA
3725 Posts |
Posted - 05 May 2001 : 19:02:59
|
the other field is the orders. i really didnt know how to insert them into the database so i just did it like that. it works and i havnt had a problem yet. here is how it works
the first number is the product id, the second is how many they ordered, the third is the price
Brad |
 |
|
Doug G
Support Moderator
    
USA
6493 Posts |
Posted - 05 May 2001 : 21:50:20
|
Ah-ha! I didn't even see the other 39.99, I fixated on the one at the end and said 'huh?' :)
====== Doug G ====== |
 |
|
redbrad0
Advanced Member
    
USA
3725 Posts |
Posted - 06 May 2001 : 16:02:43
|

now one more question.....
for some reason this is not adding can you tell me why?
<% strFirst = "39.99" strSecond = "10.99"
strTotal = strFirst + strSecond
Response.Write strTotal %>
Brad |
 |
|
HuwR
Forum Admin
    
United Kingdom
20595 Posts |
Posted - 06 May 2001 : 16:10:52
|
quote:
<% strFirst = "39.99" strSecond = "10.99" strTotal = strFirst + strSecond Response.Write strTotal%>
You are trying to add two strings as if they were numbers, try this
dblFirst = 39.99 dblSecond = 10.99 strTotal = dblFirst + dblSecond Response.Write strTotal
|
 |
|
redbrad0
Advanced Member
    
USA
3725 Posts |
Posted - 06 May 2001 : 16:21:17
|
huwr,
that worked but the real code is like this. i just wrote that so it would be easier to understand...
' LETS MAKE SURE SOMETHING IS IN THE SHOPPING CART cempty=true strProductPrice = "" for i=lbound(arrCart) to ubound(arrCart) if arrCart(i,0)<>"" and arrCart(i,1)<>"" and arrCart(i,2)<>"" then strCartString = strCartString & arrCart(i,0) & "-" & arrCart(i,1) & "-" & arrCart(i,2) & "|" strProductPrice = arrCart(i,2) strProductTotalPrice = strProductTotalPrice + strProductPrice cempty=false end if next
if cempty then ' cart empty Response.Write "cart empty" else ' cart not empty if strProductTotalPrice = "" then strProductTotalPrice = "0.00" end if if strProductShippingNHandling = "" then strProductShippingNHandling = "0.00" end if if strTaxesTotal = "" then strTaxesTotal = "0.00" end if
strSQL = "Insert Into ExhibitParts_Orders (OR_Customer_ID, OR_Date_Ordered, OR_Product_Total, OR_Shipping_N_Handling_Total, OR_Taxes_Total, OR_Products_Ordered) VALUES ('" & strCookieCustomerID & "', '" & Date & "', " & strProductTotalPrice", " & strProductShippingNHandling & ", " & strTaxesTotal & ", '" & strCartString & "')" Response.Write strSQL my_Conn.Execute (strSQL) end if
and the output of the sql string is....
Insert Into ExhibitParts_Orders (OR_Customer_ID, OR_Date_Ordered, OR_Product_Total, OR_Shipping_N_Handling_Total, OR_Taxes_Total, OR_Products_Ordered) VALUES ('1', '5/6/2001', 39.999.99, 0.00, 0.00, '4-7-39.99|1-6-9.99|')
I have two products that are in an array one is 39.99 and the other is 9.99.
i hope this makes since, if it doesnt ill try to explain more, but its just not working 
Brad |
 |
|
HuwR
Forum Admin
    
United Kingdom
20595 Posts |
Posted - 06 May 2001 : 17:58:35
|
okay try this
strProductTotalPrice = cDbl(strProductTotalPrice) + cDbl(strProductPrice)
|
 |
|
redbrad0
Advanced Member
    
USA
3725 Posts |
Posted - 07 May 2001 : 08:18:40
|
thanks that works great, but what is...
cDbl
should i use this when adding any dollar amount?
Brad |
 |
|
HuwR
Forum Admin
    
United Kingdom
20595 Posts |
Posted - 07 May 2001 : 08:36:12
|
it converts a string into a floating point number of type double much the same as cInt makes it an integer
you could also use cCur - currency type or cSng - single Type floating point
take for instance this number
19.2254576 which is of type double
cCur(19.2254576) = 19.2255 sSng(19.2254576) = 19.22546
|
 |
|
redbrad0
Advanced Member
    
USA
3725 Posts |
Posted - 07 May 2001 : 08:39:21
|
lol
cant this be simple? 
Brad |
 |
|
|
Topic  |
|