convert varchar into float in classic asp

Hi
I want to convert varchar variable into float..
Is it possible in classic asp.
If yes can you give some example for me..

When i am inserting multiple records at a time, it is accepting only varchar datatypes..when i declare it as float it is not inserting..
so i want to convert it from varchar to float to make caluculations..


Thanks
LVL 1
lucky20Asked:
Who is Participating?
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
you can try using the CDbl() function:

num = "123.456"
num = CDbl( num )
0
 
lucky20Author Commented:
is that in sql or asp?
0
 
lucky20Author Commented:
oh sorry.. i got it..
i will try this
thanks
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
lucky20Author Commented:
can u give the sample program..how u use it in real programming?

Thanks
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
maybe if you show the code you're trying to get working, I can take a look and see if I can help you directly with that
0
 
lucky20Author Commented:
To be honest, I don't know how to use this in my program..

for i=1 to 5 
                    Set sql=Server.CreateObject("ADODB.Command")  
                    sql.ActiveConnection=Conn 
                    getquantity = request.form("quantity_"& i)
                    getitemid = request.form("itemid_"& i)
                    getcase=request.form("case_"& i)
                    
                    if getitemid <> "" and getquantity <> ""and getcase <> "" then  
                    sql.commandtext="insert into items(itemid,quantity,case_i,inventory_taken)values(?,?,?,getdate())"
 sql.Parameters.Append sql.CreateParameter("@itemid", adInteger, adParamInput, , getitemid)
                    sql.Parameters.Append sql.CreateParameter("@quamntity", advarchar, adParamInput,15 , getquantity)
                    sql.Parameters.Append sql.CreateParameter("@case_i", adVarchar, adParamInput,13 , getcase) 
                    sql.Execute
                    
                    end if
Next

Open in new window

       
       
Here quantity is declared as varchar in database.
(If i declare it as float,this insert statement is not working..so declared it as varchar)
But i need quantity values to make caluculations..

Thanks
So I want to convert it to varchar to float values
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
ok I thought you wanted the ASP equivalent, but it looks like you want the sql server equivalent. have a look at http://www.w3schools.com/ado/met_comm_createparameter.asp for a list of constants you can use. you want to use adSingle or adDouble:

sql.Parameters.Append sql.CreateParameter("@quamntity", adSingle, adParamInput,15 , getquantity)

also, it looks like you may have a typo in the parameter name (@quaMntity)
0
 
lucky20Author Commented:
ad single only takes single integer(4),
or if i use ad doublemit also takes only two digit numeric value(87).
Is there anything will accept 23.94(like float values).
0
 
lucky20Author Commented:
AdDouble will accept float values..I got it..

Sorry it was my mistake. I read desription of tinyint..
Thanks for information..
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
glad I could help :)

don't forget to close the question out!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.