select top1 UserId FROM userInfor where UserId='"+username+"' and UserPwd='"+userpassword+"'
这句调试时语法有错,这句到底应该怎么些呢?谢谢
另外谁能推荐本关于这方面的确书吗 ?    谢谢!!!!!!!!

解决方案 »

  1.   

    select top1 UserId FROM userInfor where UserId= '"+username+"' and UserPwd= '"+userpassword+"' 
    把错误贴出来啊
      

  2.   

    "select top1 UserId FROM userInfor where UserId= '"+username+"' and UserPwd= '"+userpassword+"'" 
      

  3.   

    在 '"+username+" ' and UserPwd=  '"+userpassword+" '" 这句的引号的含义是什么呢/
      

  4.   

    top 和 1之间要有个空格的。
    string strSql = string.Format("select top 1 UserId FROM userInfor where UserId='{0}' and UserPwd='{1}'",username,userpassword);
      

  5.   

    在SQL里,字符串要放在''里
    C#里字符串要用""
      

  6.   

    MSDN Library for Visual Studio 2005/2003
    SQL Server 联机丛书就是最好的学习资料
      

  7.   


    "select top 1 UserId FROM userInfor where UserId= '"+username+"' and UserPwd= '"+userpassword + "' "
    1.top 与 1应该有空格;
    2. UserId= '"+username+" ' 应为 username+"' , 不应该有空格;
    3. UserPwd= '"+userpassword + " ' 应为 UserPwd= '"+userpassword + "', 不应该有空格;