UPDATE SQL 不同環境執行結果不一樣
阿新 • • 發佈:2018-12-21
背景:1.前臺:JQUERY 提交資料
2.後臺:OWIN C# 處理接收資料
3.資料庫: postgresql
============================================
問題描述: 後臺接收到前臺的資料,拼裝一個 SQL 語句
update wbs_data
set work_data='{"proName":"科研GOOD","proCode":"科研專案001","unitProName":"No1","drawingNo":"734116","proAddress":"大慶",
"partsComponents":"讓胡路鍋底",
"checkContent":"<p><br/> 這是一測試圖片<img src=\"/upload/8096b2b7d0a20cf4cd425f7a7f094b36adaf995e.jpg\" alt=\"\"
width=\"200\" height=\"200\" /> <br/></p>",
"checkOpinion":"檢查意見:<br/>1.好<br/>2.很好<br/>3.非 常好","materialDocs":"原材料質量檔案:<br/>1.測試檔案1<br/>2.測試檔案2",
"monitor":"","deputy":"","superEngineer":"","techLeader":"","date1":"","date2":"","date3":""}',work_state=1
where pwbs_id=124
我在後臺C# 用 Npgsql
public static string executeSQL(string strSQL) { Console.WriteLine("{0}", strSQL); string returnValue = string.Empty; NpgsqlConnection connection = new NpgsqlConnection(getConnectionString()); NpgsqlCommand command = new NpgsqlCommand(); command.Connection = connection; command.CommandText = strSQL; try { connection.Open(); command.ExecuteNonQuery(); //returnValue = "{\"SUCCESS\":\"執行操作:'" + strSQL + "'成功!\"}"; Console.WriteLine("{0}","--------------------you are lucky----------------"); returnValue = "{\"SUCCESS\":\"操作成功!\"}"; } catch (Exception err) { returnValue = "{\"ERROR\":\"發生以下錯誤:" + err.Message.ToString() + "\"}"; } finally { connection.Close(); } return returnValue; }
執行時總是報錯:invalid input syntax for type json
奇怪的是,當我把這個拼裝的SQL語句放在後臺服務上PSQL 執行時,居然還通過了!
why??????