Esempio n. 1
0
        public int Execute(IConnectinContext cc)
        {
            Command mCommand = Command.GetThreadCommand().AddSqlText("Delete from ").AddSqlText(mTable);

            Where.Parse(mCommand);
            return(cc.ExecuteNonQuery(mCommand));
        }
Esempio n. 2
0
        private object ExecuseAsSQL(IConnectinContext cc, SQL value)
        {
            object result = null;

            if (IsChangeDataSQL(value.Command.Text.ToString()))
            {
                result = cc.ExecuteNonQuery(value.Command);
            }
            result = cc.ExecuteScalar(value.Command);
            return(result);
        }
Esempio n. 3
0
        public int Execute(IConnectinContext cc)
        {
            Command mCommand = Command.GetThreadCommand().AddSqlText("Insert into ").AddSqlText(mTable);

            System.Text.StringBuilder names, values;
            names  = new System.Text.StringBuilder();
            values = new System.Text.StringBuilder();
            Field field;

            for (int i = 0; i < mInserFields.Count; i++)
            {
                if (i > 0)
                {
                    names.Append(",");
                    values.Append(",");
                }
                field = (Field)mInserFields[i];

                names.Append(field.Name);
                if (field.IsParameter)
                {
                    values.Append("@").Append(field.ParameterName);
                    if (field.Value != null)
                    {
                        mCommand.AddParameter(field.ParameterName, field.Value);
                    }
                    else
                    {
                        mCommand.AddParameter(field.ParameterName, DBNull.Value);
                    }
                }
                else
                {
                    values.Append(field.Value);
                }
            }
            mCommand.Text.Append("(").Append(names).Append(")").Append(" Values(").Append(values).Append(")");
            return(cc.ExecuteNonQuery(mCommand));
        }
Esempio n. 4
0
        public int Execute(IConnectinContext cc)
        {
            Command mCommand = Command.GetThreadCommand().AddSqlText("Update ").AddSqlText(mTable).AddSqlText(" set ");

            for (int i = 0; i < mFields.Count; i++)
            {
                if (i > 0)
                {
                    mCommand.Text.Append(",");
                }
                if (!mFields[i].IsParameter)
                {
                    mCommand.Text.Append(mFields[i].Name).Append("=").Append(mFields[i].Value);
                }
                else
                {
                    mCommand.Text.Append(mFields[i].Name).Append("=@").Append(mFields[i].ParameterName);
                    mCommand.AddParameter(mFields[i].ParameterName, mFields[i].Value);
                }
            }
            Where.Parse(mCommand);
            return(cc.ExecuteNonQuery(mCommand));
        }
Esempio n. 5
0
 /// <summary>
 /// 在指写数据库上执行SQL并返回受影响的数量
 /// </summary>
 /// <param name="cc">数据库访问上下文</param>
 /// <returns>int</returns>
 public int Execute(IConnectinContext cc)
 {
     return(cc.ExecuteNonQuery(mCommand));
 }
Esempio n. 6
0
        public static int Execute(this string sql, IConnectinContext cc)
        {
            Command cmd = new Command(sql);

            return(cc.ExecuteNonQuery(cmd));
        }