Beispiel #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 ";

                SQLite.Parameter[] paras = new SQLite.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 SQLite.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(changes(), -99999999)";
                object obj2 = SQLite.ExecuteScalar(ConnectionString, commandText, paras);

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

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

                SQLite.Parameter[] paras = new SQLite.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 SQLite.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_rowid(), -99999999)";
                object obj2        = SQLite.ExecuteScalar(ConnectionString, commandText, paras);

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

                if (num2 == -99999999L)
                {
                    return(0L);
                }
                return(num2);
            }