void initCommandInsert(DbDataAdapter pAdp, ITableDescriptor pTabDesc) { if (string.IsNullOrEmpty(pTabDesc.getNameFull())) { throw new MyExceptionError("Db Table Full name is null or empty"); } List <SqliteParameter> listPrm = new List <SqliteParameter>(); StringBuilder buffer = new StringBuilder(); // // buffer.Append("INSERT INTO "); //buffer.Append("\""); buffer.Append(pTabDesc.getNameFull()); //buffer.Append("\""); //buffer.Append(pTableFullName); buffer.Append(" ("); foreach (ColumnDescriptor col in pTabDesc.getColumns()) { //buffer.Append("\""); buffer.Append(col.name); //buffer.Append("\""); buffer.Append(","); } buffer.Remove(buffer.Length - 1, 1); buffer.Append(") VALUES ("); int prmIndx = 0; foreach (ColumnDescriptor col in pTabDesc.getColumns()) { SqliteParameter prm = new SqliteParameter(); ++prmIndx; prm.ParameterName = ToolSqlText.getNewParamName(prmIndx); prm.SourceVersion = DataRowVersion.Current; prm.SourceColumn = col.name; //prm.Size = col.size; listPrm.Add(prm); buffer.Append(prm.ParameterName + ","); } buffer.Remove(buffer.Length - 1, 1); buffer.Append(")"); // pAdp.InsertCommand = environment.getNewSqlCommand(buffer.ToString(), listPrm.ToArray()); }
void initCommandUpdate(DbDataAdapter pAdp, ITableDescriptor pTabDesc) { if (string.IsNullOrEmpty(pTabDesc.getNameFull())) { throw new MyExceptionError("Db Table Full name is null or empty"); } bool hasRecVers = pTabDesc.getColumn(TableDUMMY.RECVERS) != null; List <SqliteParameter> listPrm = new List <SqliteParameter>(); StringBuilder buffer = new StringBuilder(); // // buffer.Append("UPDATE "); //buffer.Append("\""); buffer.Append(pTabDesc.getNameFull()); //buffer.Append("\""); //buffer.Append(pTableFullName); buffer.Append(" SET "); int prmIndx = 0; foreach (ColumnDescriptor col in pTabDesc.getColumns()) { SqliteParameter prm = new SqliteParameter(); ++prmIndx; prm.ParameterName = ToolSqlText.getNewParamName(prmIndx); prm.SourceVersion = DataRowVersion.Current; prm.SourceColumn = col.name; //prm.Size = col.size; listPrm.Add(prm); //buffer.Append("\""); buffer.Append(string.Format("{0} = {1}", col.name, prm.ParameterName)); //buffer.Append("\""); buffer.Append(","); } buffer.Remove(buffer.Length - 1, 1); buffer.Append(" WHERE "); string[] arr_ = hasRecVers ? new string[] { TableDUMMY.LOGICALREF, TableDUMMY.RECVERS } : new string[] { TableDUMMY.LOGICALREF }; buffer.Append("("); for (int i = 0; i < arr_.Length; ++i) { if (i > 0) { buffer.Append(" AND "); } SqliteParameter prm = new SqliteParameter(); ++prmIndx; prm.ParameterName = ToolSqlText.getNewParamName(prmIndx); prm.SourceVersion = DataRowVersion.Original; prm.SourceColumn = arr_[i]; //prm.Size = col.size; listPrm.Add(prm); buffer.Append(string.Format("{0} = {1}", prm.SourceColumn, prm.ParameterName)); } buffer.Append(")"); pAdp.UpdateCommand = environment.getNewSqlCommand(buffer.ToString(), listPrm.ToArray()); }