public void setParameters(int cursor, IFieldSetter stmt, Object[] parms) { List <ParDef> parmdefs = stmt.ParameterDefinition; int idx = 0; int idxParmCollection = 1; object[] parmsValues = new object[parmdefs.Count]; foreach (ParDef pdef in parmdefs) { bool valueIsNull = false; try { if (pdef.InOut) { stmt.RegisterInOutParameter(idxParmCollection, null); } else if (pdef.Out) { stmt.RegisterOutParameter(idxParmCollection, null); continue; } if (pdef.Nullable) { valueIsNull = (bool)parms[idx]; if (valueIsNull) { stmt.setNull(idxParmCollection, DBNull.Value); } idx += 1; } parmsValues[idxParmCollection - 1] = parms[idx]; if (!valueIsNull) { switch (pdef.GxType) { case GXType.Char: case GXType.NChar: case GXType.VarChar: if (pdef.AddAtt && !pdef.Preload) { if (!string.IsNullOrEmpty(pdef.Tbl) && !string.IsNullOrEmpty(pdef.Fld)) { stmt.SetParameterMultimedia(idxParmCollection, (string)parms[idx], (string)parmsValues[pdef.ImgIdx], pdef.Tbl, pdef.Fld); } else { stmt.SetParameterMultimedia(idxParmCollection, (string)parms[idx], (string)parmsValues[pdef.ImgIdx]); } } else { if (pdef.GxType == GXType.VarChar) { if (pdef.ChkEmpty) { stmt.SetParameterVChar(idxParmCollection, (string)parms[idx]); } else { stmt.SetParameterObj(idxParmCollection, parms[idx]); } } else { if (pdef.ChkEmpty) { stmt.SetParameterChar(idxParmCollection, (string)parms[idx]); } else { stmt.SetParameter(idxParmCollection, (string)parms[idx]); } } } break; case GXType.NVarChar: if (pdef.ChkEmpty) { stmt.SetParameterVChar(idxParmCollection, (string)parms[idx]); } else { stmt.SetParameter(idxParmCollection, (string)parms[idx]); } break; case GXType.NClob: case GXType.Clob: case GXType.LongVarChar: if (pdef.ChkEmpty) { stmt.SetParameterLVChar(idxParmCollection, (string)parms[idx]); } else { stmt.SetParameter(idxParmCollection, (string)parms[idx]); } break; case GXType.Date: stmt.SetParameter(idxParmCollection, (DateTime)parms[idx]); break; case GXType.DateAsChar: case GXType.DateTime: stmt.SetParameterDatetime(idxParmCollection, (DateTime)parms[idx]); break; case GXType.DateTime2: stmt.SetParameterDatetime(idxParmCollection, (DateTime)parms[idx], true); break; case GXType.Blob: stmt.SetParameterBlob(idxParmCollection, (string)parms[idx], pdef.InDB); break; case GXType.UniqueIdentifier: stmt.SetParameter(idxParmCollection, (Guid)parms[idx]); break; case GXType.Geography: case GXType.Geopoint: case GXType.Geoline: case GXType.Geopolygon: stmt.SetParameter(idxParmCollection, (Geospatial)parms[idx], pdef.GxType); break; default: stmt.SetParameterObj(idxParmCollection, parms[idx]); break; } } idx += 1; idxParmCollection += 1; } catch (InvalidCastException ex) { string msg = this.GetType() + ".setParameters error parameterName:" + pdef.Name + " parameterType:" + pdef.GxType; GXLogging.Error(log, ex, msg + " value:" + parms[idx]); throw new Exception("Invalid parameter conversion at " + msg, ex); } } }