Пример #1
0
            public long Update(string ConnectionString, string Condition)
            {
                if (this.Fields.Count < 1)
                {
                    return(-101L);
                }
                Condition = Condition.Trim();
                string commandText = "update `" + this.TableName + "` set ";

                MySQL.Parameter[] paras = new MySQL.Parameter[this.Fields.Count];
                for (int i = 0; i < this.Fields.Count; i++)
                {
                    if (i > 0)
                    {
                        commandText = commandText + ", ";
                    }
                    string str2 = commandText;
                    commandText = str2 + "`" + this.Fields[i].Name + "` = ?" + this.Fields[i].CanonicalIdentifierName;
                    paras[i]    = new MySQL.Parameter(this.Fields[i].CanonicalIdentifierName, this.Fields[i].DbType, 0, ParameterDirection.Input, this.Fields[i].Value);
                }
                if (!string.IsNullOrEmpty(Condition))
                {
                    commandText = commandText + " where " + Condition;
                }
                commandText = commandText + "; select ifnull(ROW_COUNT(), -99999999)";
                object obj2 = MySQL.ExecuteScalar(ConnectionString, commandText, paras);

                if (obj2 == null)
                {
                    return(-102L);
                }
                this.Fields.Clear();
                long num2 = (long)obj2;

                if (num2 == -99999999L)
                {
                    return(0L);
                }
                return(num2);
            }
Пример #2
0
            public long Insert(string ConnectionString)
            {
                if (this.Fields.Count < 1)
                {
                    return(-101L);
                }
                string str  = "";
                string str2 = "";

                MySQL.Parameter[] paras = new MySQL.Parameter[this.Fields.Count];
                for (int i = 0; i < this.Fields.Count; i++)
                {
                    if (i > 0)
                    {
                        str  = str + ", ";
                        str2 = str2 + ", ";
                    }
                    str      = str + "`" + this.Fields[i].Name + "`";
                    str2     = str2 + "?" + this.Fields[i].CanonicalIdentifierName;
                    paras[i] = new MySQL.Parameter(this.Fields[i].CanonicalIdentifierName, this.Fields[i].DbType, 0, ParameterDirection.Input, this.Fields[i].Value);
                }
                string commandText = "insert into `" + this.TableName + "` (" + str + ") values (" + str2 + "); select ifnull(LAST_INSERT_ID(), -99999999)";
                object obj2        = MySQL.ExecuteScalar(ConnectionString, commandText, paras);

                if (obj2 == null)
                {
                    return(-102L);
                }
                this.Fields.Clear();
                long num2 = (long)obj2;

                if (num2 == -99999999L)
                {
                    return(0L);
                }
                return(num2);
            }
Пример #3
0
 public long Insert(string ConnectionString)
 {
     if (this.Fields.Count < 1)
     {
         return -101L;
     }
     string str = "";
     string str2 = "";
     MySQL.Parameter[] paras = new MySQL.Parameter[this.Fields.Count];
     for (int i = 0; i < this.Fields.Count; i++)
     {
         if (i > 0)
         {
             str = str + ", ";
             str2 = str2 + ", ";
         }
         str = str + "`" + this.Fields[i].Name + "`";
         str2 = str2 + "?" + this.Fields[i].CanonicalIdentifierName;
         paras[i] = new MySQL.Parameter(this.Fields[i].CanonicalIdentifierName, this.Fields[i].DbType, 0, ParameterDirection.Input, this.Fields[i].Value);
     }
     string commandText = "insert into `" + this.TableName + "` (" + str + ") values (" + str2 + "); select ifnull(LAST_INSERT_ID(), -99999999)";
     object obj2 = MySQL.ExecuteScalar(ConnectionString, commandText, paras);
     if (obj2 == null)
     {
         return -102L;
     }
     this.Fields.Clear();
     long num2 = (long) obj2;
     if (num2 == -99999999L)
     {
         return 0L;
     }
     return num2;
 }
Пример #4
0
 public long Update(string ConnectionString, string Condition)
 {
     if (this.Fields.Count < 1)
     {
         return -101L;
     }
     Condition = Condition.Trim();
     string commandText = "update `" + this.TableName + "` set ";
     MySQL.Parameter[] paras = new MySQL.Parameter[this.Fields.Count];
     for (int i = 0; i < this.Fields.Count; i++)
     {
         if (i > 0)
         {
             commandText = commandText + ", ";
         }
         string str2 = commandText;
         commandText = str2 + "`" + this.Fields[i].Name + "` = ?" + this.Fields[i].CanonicalIdentifierName;
         paras[i] = new MySQL.Parameter(this.Fields[i].CanonicalIdentifierName, this.Fields[i].DbType, 0, ParameterDirection.Input, this.Fields[i].Value);
     }
     if (!string.IsNullOrEmpty(Condition))
     {
         commandText = commandText + " where " + Condition;
     }
     commandText = commandText + "; select ifnull(ROW_COUNT(), -99999999)";
     object obj2 = MySQL.ExecuteScalar(ConnectionString, commandText, paras);
     if (obj2 == null)
     {
         return -102L;
     }
     this.Fields.Clear();
     long num2 = (long) obj2;
     if (num2 == -99999999L)
     {
         return 0L;
     }
     return num2;
 }