2016-04-22 27 views
0

嘿,我使用Dapper.Contrib小巧玲瓏的Contrib插入MySQL的語法錯誤

MySQL中獲取語法錯誤
MySQL server version for the right syntax to use near '[cause_code],[cause_name]) values ('000-DDH', 'No Money')' at line 1 

對插入在MySQL正確的語法是

"Insert Into `tbl_cause` (`cause_code`, `cause_name`) VALUES('blah', 'blah')"; 

我的代碼:

var entity = new Cause { cause_code = "000-DDH", cause_name = "No Money" }; 
     using (IDbConnection cn = ConStr.Conn()) 
     { 
      long ins = cn.Insert(entity); 
      if (ins > 0) 
      { 
       MessageBox.Show("Cause Code: " + entity.cause_code + " Successfully Added!"); 
       GDRD(); 
      } 
      else { 
       MessageBox.Show("Cause Code: " + entity.cause_code + " While trying to Add an Error Occurred!"); 
      } 
     } 

這個怎麼解決?在此先感謝

回答

0

它又是你:) Cause類有Table("tbl_cause")指令? 閱讀短小精靈contrib擴展文檔here