码迷,mamicode.com
首页 > 数据库 > 详细

UPDATE SQL 不同环境执行结果不一样

时间:2018-12-21 01:07:02      阅读:245      评论:0      收藏:0      [点我收藏+]

标签:测试文件   command   ali   a20   sql 语句   monit   hle   nio   文件   

背景: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??????

 

UPDATE SQL 不同环境执行结果不一样

标签:测试文件   command   ali   a20   sql 语句   monit   hle   nio   文件   

原文地址:https://www.cnblogs.com/ssqhan/p/10153172.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!