none
SqlDataSet,中的查询语句,为什么里面那二条都不能执行?谢谢 RRS feed

  • 问题

  • Dim objdataadapte As New SqlDataAdapter( _
       "select authors.au_id,au_lname,au_fname,titles.title_id,title,price" & _
    "from authors,titles,titleauthor" & _
    "where authors.au_id=titleauthor.au_id" & _
    "and titleauthor.title_id=titles.title_id" & _
    "order by au_lname", objconn)

     ''"SELECT authors.au_id,au_lname,au_fname," & _
        ''"titles.title_id,title,price" & _
        ''"FROM authors " & _
        ''"JOIN titleauthor ON authors.au_id = titleauthor.au_id " & _
        ''"JOIN titles ON titleauthor.title_id = titles.title_id " & _
        ''"ORDER BY au_lname ", objconn)

    2013年4月9日 9:23

答案

  • 你好,好像你的sql裡少了些 space

    1) ".....,price" & "from....." = "....,pricefrom"
    2) "...author" & "where..." = "...authorwhere"
    等等,所以不能運作


    大家一齊探討、學習和研究,謝謝!
    MCSD, MCAD, MCSE+I, MCDBA, MCDST, MCSA, MCTS, MCITP, MCPD,
    MCT, Microsoft Community Star(TW & HK),
    Microsoft MVP for VB.NET since 2003
    My MSMVP Blog

    2013年4月9日 10:17

全部回复

  • 你好,好像你的sql裡少了些 space

    1) ".....,price" & "from....." = "....,pricefrom"
    2) "...author" & "where..." = "...authorwhere"
    等等,所以不能運作


    大家一齊探討、學習和研究,謝謝!
    MCSD, MCAD, MCSE+I, MCDBA, MCDST, MCSA, MCTS, MCITP, MCPD,
    MCT, Microsoft Community Star(TW & HK),
    Microsoft MVP for VB.NET since 2003
    My MSMVP Blog

    2013年4月9日 10:17
  • 建议以后先把SQL语句在SQL Management Studio中测试之后再黏贴,或者直接调用存储过程:

    Dim objdataadapte As New SqlDataAdapter( _
    "select authors.au_id,au_lname,au_fname,titles.title_id,title,price " & _
    "from authors,titles,titleauthor " & _
    "where authors.au_id=titleauthor.au_id " & _
    "and titleauthor.title_id=titles.title_id " & _
    "order by au_lname", objconn)

    If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer

    Help by clicking:
    Click here to donate your rice to the poor
    Click to Donate
    Click to feed Dogs & Cats

    2013年4月11日 7:51
    版主
  • Hi KENLIN:

    Thank you very much. it's great. i spent much time about it. thank you again!

    Wayne

    2013年4月11日 8:23
  • thanks for your suggestion.
    2013年4月11日 8:24