开发者

select command for access database

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


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.


 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);


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜