JSON 객체 벌크 삽입 데이터베이스(비저장 프로세스)[C#]

2681 단어
                field_array ={"seq_id","BYD_PN","Qty","WCode",
                                   "RealQty","Work_Order_No","Station_Code",
                                   "Line_Code","Req_Timestamp"
                                  };

                string field_info = "";
                for (int j = 0; j < field_array.Length; j++)
                {
                    field_info += field_array[j] + ",";
                }

                string sql = @"insert into smt_kanbanrequest (" + field_info.TrimEnd(',') + ") values ";

                string sqlvalues = "";
                List request_list = request_orderlist_json.Request_List;
                string Seq_ID = request_orderlist_json.Seq_ID;
                string Work_Order_No = request_orderlist_json.Work_Order_No;

                for (int k = 0; k < request_list.Count; k++)
                {
                    field_array[0] = Seq_ID;
                    field_array[1] = request_list[k].BYD_PN;
                    field_array[2] = request_list[k].Qty.ToString();
                    field_array[3] = request_list[k].WCode;
                    field_array[4] = request_list[k].Qty.ToString();
                    field_array[5] = Work_Order_No;
                    field_array[6] = request_list[k].Station_Code;
                    field_array[7] = request_list[k].Line_Code;
                    field_array[8] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                    string info = "";
                    for (int m = 0; m < field_array.Length; m++)
                    {
                        info += "'" + field_array[m] + "',";
                    }

                    sqlvalues += "(" + info.TrimEnd(',') + "),";
                }

                bool flag = OdbcServerHelper.insertSqlBat(sql, sqlvalues);
        /// 
        /// sql         
        /// 
        /// sql   
        ///     
        /// 
        public static bool insertSqlBat(string sql, string sqlvalues)
        {
            bool rtnbool = false;

            if (sqlvalues != "")
            {
                sqlvalues = sqlvalues.TrimEnd(',');
                if (OdbcServerDB.insert(sql + sqlvalues) > 0)
                {
                    rtnbool = true;
                }
            }
            return rtnbool;
        }

좋은 웹페이지 즐겨찾기