views:

36

answers:

3
OleDbCommand cmdpic = new OleDbCommand
          ("select * from sub_category where id_s=" 
            + Request.QueryString["id_s"] 
            +"or"+"order by sub_id desc", concars);

it shows error

what is the correct command

A: 

Hi,

OleDbCommand cmdpic = new OleDbCommand
      ("select * from sub_category where id_s=" 
        + Request.QueryString["id_s"] 
        +" or "+"order by sub_id desc", concars);

I believe you forgot spaces in the "Or"

And providing the error message is of course very helpful :)

Edit: It appears you should remove the OR indeed.

Trefex
"select * from sub_category where id_s=" + Request.QueryString["id_s"] + "or" + "order by sub_id desc"its not working please give me correct command
azeem
i am success to do it "select * from sub_category where id_s=" + Request.QueryString["id_s"] + " order by sub_id desc
azeem
Yep, removing the OR does the trick.
Trefex
A: 
 Request.QueryString["id_s"] 
        +"or"+"order by sub_id desc"

You have no spaces in there. Try this:

OleDbCommand cmdpic = new OleDbCommand
      ("select * from sub_category where id_s=" 
        + Request.QueryString["id_s"] 
        +" or "+"order by sub_id desc", concars);
fire.eagle
it shows error Exception Details: System.Data.OleDb.OleDbException: Syntax error (missing operator) in query expression 'id_s=10ororder by sub_id desc'.Source Error:
azeem
Are you sure you subbed in the command at the bottom of what I wrote? That error message still shows the query as having no spaces in it.
fire.eagle
+2  A: 

Actually, I think the real error was putting in the OR in the first place. The missing spaces would have caused a problem, but that was invalid syntax anyway -- select x from y where a=b or order by z is not valid in any SQL I have heard of.

MJB