开发者

select command for access database

开发者 https://www.devze.com 2023-01-06 12:15 出处:网络
OleDbCommand cmdpic = new OleDbCommand (\"select * from sub_category where id_s=\" + Request.QueryString[\"id_s\"]
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

精彩评论

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