Solved

convert varchar into float in classic asp

Posted on 2011-03-21
10
3,354 Views
Last Modified: 2012-08-13
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
0
Comment
Question by:lucky20
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 33

Accepted Solution

by:
Big Monty earned 500 total points
ID: 35180395
you can try using the CDbl() function:

num = "123.456"
num = CDbl( num )
0
 
LVL 1

Author Comment

by:lucky20
ID: 35180409
is that in sql or asp?
0
 
LVL 1

Author Comment

by:lucky20
ID: 35180419
oh sorry.. i got it..
i will try this
thanks
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 1

Author Comment

by:lucky20
ID: 35189901
can u give the sample program..how u use it in real programming?

Thanks
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 35189981
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
 
LVL 1

Author Comment

by:lucky20
ID: 35190398
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
 
LVL 33

Assisted Solution

by:Big Monty
Big Monty earned 500 total points
ID: 35190524
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
 
LVL 1

Author Comment

by:lucky20
ID: 35191402
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
 
LVL 1

Author Comment

by:lucky20
ID: 35191416
AdDouble will accept float values..I got it..

Sorry it was my mistake. I read desription of tinyint..
Thanks for information..
0
 
LVL 33

Assisted Solution

by:Big Monty
Big Monty earned 500 total points
ID: 35191832
glad I could help :)

don't forget to close the question out!
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question