带有select语句的mysql C#语法问题

时间:2014-04-08 14:10:10

标签: mysql syntax

您好我希望对我的SQL语法提供一些帮助我非常难以理解如何更改它以显示以下ID,作者,标题来自书籍

public  Book    getBookByID(int bookID) 
{   
      System.Diagnostics.Debug.WriteLine("Attempting    to  get book    with    ID: "   +   bookID);    
      try   
      { 
          conn  =   new MySqlConnection(cs);    
          conn.Open();

          string stm = ("SELECT Id, AuthorId,Title  FROM    books   WHERE   Id  =   " + bookID);    
          MySqlCommand  cmd =   new MySqlCommand(stm,   conn);  
          rdr   =   cmd.ExecuteReader();        

我收到了这个错误

  

MySql.Data.MySqlClient.MySqlException(0x80004005):您的SQL语法中有错误;查看与您的MySQL服务器版本相对应的手册,以便使用“SELECT Id,AuthorId,Title FROM books WHERE Id = 1'在第1行

0 个答案:

没有答案