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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 please help me as soon as possible

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 that

qty=request.form("qty")
rate=request.form("rate")

sql= select * from table where p_qty = qty and rate_per_price=rate

i am getting the problem in placing the commas '"in the proper place

please help me as soon as possible

salman

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 TABLE
WHERE p_qty = 'qty' AND
rate_per_price = 'rate'



-ec
Go to Top of Page

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= " & rate

Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page

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 text
qty=request.form("qty") // qty is a number

here is the query in which i am getting syntax error

sql= "select * from table where product = " & product & " and min_qty = " & qty

i am getting syntax error due to commas like " and ' etc, please solve My problem, i am waiting for your reply. thank you








salman
Go to Top of Page

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>
Go to Top of Page

salman
Starting Member

5 Posts

Posted - 2004-08-11 : 22:13:51
Dear Michael

in the first query you assume the both product and qty as interger, the code was perfect

in the 2nd query you assume the both product and qty as string, the code is perfect

i 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 code

sql= "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 * qty

thank you once again for your kindness




salman
Go to Top of Page

salman
Starting Member

5 Posts

Posted - 2004-08-11 : 23:02:16
Michael

your code done the magic, its working perfectly now , thanks a lot for all your kindness, you really solved my problem

salman
Go to Top of Page

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. :)
Go to Top of Page
   

- Advertisement -