Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
salman
Starting Member
5 Posts |
Posted - 2004-08-11 : 20:08:40
|
| i am trying to write a query since a long time. i pass passing 2 from values to other pages after thatqty=request.form("qty")rate=request.form("rate")sql= select * from table where p_qty = qty and rate_per_price=ratei am getting the problem in placing the commas '"in the proper placeplease help me as soon as possiblesalman |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2004-08-11 : 20:14:34
|
You didn't give us very much to work with. is this what you are looking for?SELECT * FROM TABLEWHERE p_qty = 'qty' AND rate_per_price = 'rate' -ec |
 |
|
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2004-08-11 : 20:28:28
|
| I generally don't reply to these type of posts, but here goes.sql= "select * from table where p_qty = " & qty & " and rate_per_price= " & rateMichael<Yoda>Use the Search page you must. Find the answer you will.</Yoda> |
 |
|
|
salman
Starting Member
5 Posts |
Posted - 2004-08-11 : 21:10:44
|
| Micheal!you are very near to solve my problem, i hope you can help me one more time.please see the same query again. i am passing 2 form values to this page from previous page.product=request.form("product") //product is a textqty=request.form("qty") // qty is a numberhere is the query in which i am getting syntax errorsql= "select * from table where product = " & product & " and min_qty = " & qtyi am getting syntax error due to commas like " and ' etc, please solve My problem, i am waiting for your reply. thank yousalman |
 |
|
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2004-08-11 : 21:22:28
|
Oh!, I should have put this in my first post.You proably need single quotes around those variables since they are strings.sql= "select * from table where product = '" & product & "' and min_qty = '" & qty & "'" Michael<Yoda>Use the Search page you must. Find the answer you will.</Yoda> |
 |
|
|
salman
Starting Member
5 Posts |
Posted - 2004-08-11 : 22:13:51
|
| Dear Michaelin the first query you assume the both product and qty as interger, the code was perfectin the 2nd query you assume the both product and qty as string, the code is perfecti want that you assume product as string and qty as float or integer and write the query again or tell me how to convert a string data type to integer or float(just last time for me) because i am getting type mismatch rs error i am sending you the further codesql= "select * from ahmad_brothers where product = '" & product & "' and min_qty = '" & qty & "'"con.execute(sql)rate=rs("rate_per_piece")rate=cInt(rate)qty=rs("min_qty")qty=cInt(qty)bill = rate * qtythank you once again for your kindnesssalman |
 |
|
|
salman
Starting Member
5 Posts |
Posted - 2004-08-11 : 23:02:16
|
| Michaelyour code done the magic, its working perfectly now , thanks a lot for all your kindness, you really solved my problemsalman |
 |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2004-08-12 : 05:31:29
|
| Bear in mind that it's good practice never to put form values directly into your sql string, it leaves you open to all manner of hacking.You'd be better off setting up a stored procedure and calling it from the command object.-------Moo. :) |
 |
|
|
|
|
|
|
|