当前位置: 首页>>代码示例>>C#>>正文


C# Database.ExecuteNonQuery方法代码示例

本文整理汇总了C#中Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteNonQuery方法的典型用法代码示例。如果您正苦于以下问题:C# Database.ExecuteNonQuery方法的具体用法?C# Database.ExecuteNonQuery怎么用?C# Database.ExecuteNonQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Practices.EnterpriseLibrary.Data.Database的用法示例。


在下文中一共展示了Database.ExecuteNonQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Insert

        public bool Insert(Photo photo, Database db, DbTransaction transaction = null)
        {
            DbCommand command = db.GetStoredProcCommand("usp_PhotoInsert");
            photo.PhotoId = Guid.NewGuid();

            db.AddInParameter(command, "PhotoId", DbType.Guid, photo.PhotoId);
            db.AddInParameter(command, "FileName", DbType.String, photo.FileName);
            db.AddInParameter(command, "FilePath", DbType.String, photo.FilePath);
            db.AddInParameter(command, "ContextId", DbType.Guid, photo.ContextId);
            db.AddInParameter(command, "Description", DbType.String, photo.Description);
            db.AddInParameter(command, "ContextTypeId", DbType.Int32, (int)photo.ContextType);
            db.AddInParameter(command, "ContextSubTypeId", DbType.Int32, photo.ContextSubTypeId);
            db.AddInParameter(command, "PhotoCategoryId", DbType.Int32, (int)photo.PhotoCategory);

            db.AddInParameter(command, "IsDeleted", DbType.String, photo.IsDeleted);
            db.AddInParameter(command, "CreatedBy", DbType.Guid, photo.CreatedBy);
            db.AddOutParameter(command, "CreatedDate", DbType.DateTime, 30);

            if (transaction == null)
            {
                db.ExecuteNonQuery(command);
            }
            else
            {
                db.ExecuteNonQuery(command, transaction);
            }

            photo.CreatedDate = Convert.ToDateTime(db.GetParameterValue(command, "CreatedDate").ToString());
            photo.UpdatedDate = photo.CreatedDate;

            return true;
        }
开发者ID:nirshandileep,项目名称:RHP,代码行数:32,代码来源:PhotoDAO.cs

示例2: Insert

        public bool Insert(School school, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_SchoolInsert");

            db.AddInParameter(command, "SchoolId", DbType.Guid, Guid.NewGuid());
            db.AddInParameter(command, "Name", DbType.String, school.Name);
            db.AddInParameter(command, "StreetAddress", DbType.String, school.StreetAddress);
            db.AddInParameter(command, "City", DbType.String, school.City);
            db.AddInParameter(command, "State", DbType.String, school.State);
            db.AddInParameter(command, "Zip", DbType.String, school.Zip);
            db.AddInParameter(command, "ContactNumber", DbType.String, school.ContactNumber);
            db.AddInParameter(command, "Email", DbType.String, school.Email);
            db.AddInParameter(command, "Location", DbType.String, school.Location);
            db.AddInParameter(command, "WebsiteURL", DbType.String, school.WebsiteURL);
            db.AddInParameter(command, "RatingValue", DbType.Decimal, school.RatingValue);
            db.AddInParameter(command, "CreatedBy", DbType.Guid, school.CreatedBy);

            db.AddOutParameter(command, "CreatedDate", DbType.DateTime, 30);

            if (transaction == null)
            {
                db.ExecuteNonQuery(command);
            }
            else
            {
                db.ExecuteNonQuery(command, transaction);
            }

            school.CreatedDate = Convert.ToDateTime(db.GetParameterValue(command, "CreatedDate").ToString());
            school.UpdatedDate = school.CreatedDate;

            return true;
        }
开发者ID:nirshandileep,项目名称:RHP,代码行数:33,代码来源:SchoolDAO.cs

示例3: Insert

        public bool Insert(OptionItem OptionItem, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_OptionItemInsert");

            db.AddInParameter(command, "Name", DbType.String, OptionItem.Name);
            db.AddInParameter(command, "Description", DbType.String, OptionItem.Description);
            db.AddInParameter(command, "IsDeleted", DbType.Boolean, OptionItem.IsDeleted);
            db.AddInParameter(command, "OptionId", DbType.Int16, OptionItem.OptionId);
            db.AddInParameter(command, "CreatedBy", DbType.Guid, OptionItem.CreatedBy);

            db.AddOutParameter(command, "OptionItemId", DbType.Int16, 3);

            if (transaction == null)
            {
                db.ExecuteNonQuery(command);
            }
            else
            {
                db.ExecuteNonQuery(command, transaction);
            }

            OptionItem.OptionItemId = Convert.ToInt16(db.GetParameterValue(command, "OptionItemId").ToString());

            return true;
        }
开发者ID:nirshandileep,项目名称:RHP,代码行数:25,代码来源:PropertyOptionItemDAO.cs

示例4: Insert

        public bool Insert(PartialUser partialUser, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_PartialUserInsert");

            partialUser.PartialUserId = Guid.NewGuid();

            db.AddInParameter(command, "PartialUserId", DbType.Guid, partialUser.PartialUserId);
            db.AddInParameter(command, "Email", DbType.String, partialUser.Email);
            db.AddInParameter(command, "FirstName", DbType.String, partialUser.FirstName);
            db.AddInParameter(command, "MiddleName", DbType.String, partialUser.MiddleName);
            db.AddInParameter(command, "LastName", DbType.String, partialUser.LastName);
            db.AddInParameter(command, "Contact", DbType.String, partialUser.Contact);
            db.AddInParameter(command, "RoleId", DbType.Guid, partialUser.RoleId);
            db.AddInParameter(command, "UserId", DbType.Guid, partialUser.UserId);
            db.AddInParameter(command, "PartialHouseId", DbType.Guid, partialUser.PartialHouseId);
            db.AddInParameter(command, "IsDeleted", DbType.Boolean, partialUser.IsDeleted);
            db.AddInParameter(command, "CreatedBy", DbType.Guid, partialUser.CreatedBy);

            db.AddOutParameter(command, "CreatedDate", DbType.DateTime, 30);

            db.ExecuteNonQuery(command, transaction);

            partialUser.CreatedDate = Convert.ToDateTime(db.GetParameterValue(command, "CreatedDate").ToString());
            partialUser.UpdatedDate = partialUser.CreatedDate;

            return true;
        }
开发者ID:nirshandileep,项目名称:RHP,代码行数:27,代码来源:PartialUserDAO.cs

示例5: Insert

        public bool Insert(Student student, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_StudentInsert");

            db.AddInParameter(command, "StudentId", DbType.Guid, Guid.NewGuid());
            db.AddInParameter(command, "UserId", DbType.Guid, student.StudentUser.UserId);
            db.AddInParameter(command, "SchoolId", DbType.Guid, student.School.SchoolId);
            db.AddInParameter(command, "IsDeleted", DbType.Boolean, student.IsDeleted);
            db.AddInParameter(command, "Year", DbType.String, student.School.Year);
            db.AddInParameter(command, "StartYear", DbType.String, student.StartYear);
            db.AddInParameter(command, "StartMonth", DbType.String, student.StartMonth);
            db.AddInParameter(command, "Status", DbType.String, student.Status);
            db.AddInParameter(command, "PreviousSchoolInfo", DbType.String, student.PreviousSchoolInfo);
            db.AddInParameter(command, "PreviousSchool", DbType.String, student.PreviousSchool);
            db.AddInParameter(command, "MajorId", DbType.Int16, student.MajorId);
            db.AddInParameter(command, "CreatedBy", DbType.Guid, student.CreatedBy);

            db.AddOutParameter(command, "CreatedDate", DbType.DateTime, 30);

            db.ExecuteNonQuery(command, transaction);

            student.CreatedDate = Convert.ToDateTime(db.GetParameterValue(command, "CreatedDate").ToString());
            student.UpdatedDate = student.CreatedDate;

            return true;
        }
开发者ID:nirshandileep,项目名称:RHP,代码行数:26,代码来源:StudentDAO.cs

示例6: Insert

        public bool Insert(Option Option, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_OptionInsert");

            db.AddInParameter(command, "Name", DbType.String, Option.Name);
            db.AddInParameter(command, "Description", DbType.String, Option.Description);
            db.AddInParameter(command, "OptionCategoryId", DbType.Int16, Option.OptionCategoryId);
            db.AddInParameter(command, "ParentOptionId", DbType.Int16, Option.ParentOptionId);
            db.AddInParameter(command, "IsDeleted", DbType.Boolean, Option.IsDeleted);
            db.AddInParameter(command, "IsMultiSelect", DbType.Boolean, Option.IsMultiSelect);
            db.AddInParameter(command, "Points", DbType.Int16, Option.Points);

            db.AddOutParameter(command, "OptionId", DbType.Int16, 3);

            if (transaction == null)
            {
                db.ExecuteNonQuery(command);
            }
            else
            {
                db.ExecuteNonQuery(command, transaction);
            }

            Option.OptionId = Convert.ToInt16(db.GetParameterValue(command, "OptionId").ToString());

            return true;
        }
开发者ID:nirshandileep,项目名称:RHP,代码行数:27,代码来源:PropertyOptionDAO.cs

示例7: DeleteRoleRightsByRoleId

 public bool DeleteRoleRightsByRoleId(Role roles, Database db, DbTransaction transaction)
 {
     DbCommand dbCommand = db.GetStoredProcCommand("usp_RoleRightDelete");
     db.AddInParameter(dbCommand, "RoleId", DbType.Guid, roles.RoleId);
     db.ExecuteNonQuery(dbCommand, transaction);
     return true;
 }
开发者ID:nirshandileep,项目名称:DairyManager,代码行数:7,代码来源:RoleDAO.cs

示例8: RegistrarAutos

        //Funcion para registrar autos
        public int RegistrarAutos(Autos DatosA, DbTransaction tran, Database db)
        {
            string sqlCommand = "dbo.insertar_autos";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

            try {
                db.AddInParameter(dbCommand, "@INTplaca", DbType.Int32, Utilerías.ObtenerValor(DatosA.Placa));
                db.AddInParameter(dbCommand, "@STRmarca", DbType.String, Utilerías.ObtenerValor(DatosA.Marca));
                db.AddInParameter(dbCommand, "@STRmodelo", DbType.String, Utilerías.ObtenerValor(DatosA.Modelo));
                db.AddInParameter(dbCommand, "@INTanno", DbType.Int32, Utilerías.ObtenerValor(DatosA.Año));
                db.AddInParameter(dbCommand, "@INTnumero_vin", DbType.Int32, Utilerías.ObtenerValor(DatosA.Vin));
                db.AddInParameter(dbCommand, "@STRcolor", DbType.String, Utilerías.ObtenerValor(DatosA.Color));
                db.AddOutParameter(dbCommand, "@nStatus", DbType.Int16, 2);
                db.AddOutParameter(dbCommand, "@strMessage", DbType.String, 250);
                db.AddOutParameter(dbCommand, "@INTid_Auto", DbType.Int32, 4);

                db.ExecuteNonQuery(dbCommand, tran);

                if (int.Parse(db.GetParameterValue(dbCommand, "@nStatus").ToString()) > 0)
                    throw new Exception(db.GetParameterValue(dbCommand, "@strMessage").ToString());

                //retorna el id del auto que acaba de registrar
                return int.Parse(db.GetParameterValue(dbCommand, "@INTid_Auto").ToString());

            } catch (Exception ex) {
                throw new Exception(ex.Message);
            }
        }
开发者ID:alonsovb,项目名称:jazz-taller,代码行数:29,代码来源:RegistrosDAL.cs

示例9: Delete

        public bool Delete(OptionCategory ropertyOptionCategory, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_OptionCategoryDelete");
            db.AddInParameter(command, "OptionCategoryId", DbType.Guid, ropertyOptionCategory.OptionCategoryId);

            db.ExecuteNonQuery(command, transaction);
            return true;
        }
开发者ID:nirshandileep,项目名称:RHP,代码行数:8,代码来源:OptionCategoryDAO.cs

示例10: Insert

        public bool Insert(PartialHouse partialHouse, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_PartialHouseInsert");

            partialHouse.PartialHouseId = Guid.NewGuid();
            db.AddInParameter(command, "PartialHouseId", DbType.Guid, partialHouse.PartialHouseId);
            db.AddInParameter(command, "PartialUserId", DbType.Guid, partialHouse.PartialUserId);
            db.AddInParameter(command, "StateId", DbType.Int32, partialHouse.StateId);
            db.AddInParameter(command, "ZipCode", DbType.String, partialHouse.ZipCode);
            db.AddInParameter(command, "City", DbType.String, partialHouse.City);
            db.AddInParameter(command, "Address", DbType.String, partialHouse.Address);
            db.AddInParameter(command, "IsDeleted", DbType.Boolean, partialHouse.IsDeleted);
            db.AddInParameter(command, "CreatedBy", DbType.Guid, partialHouse.CreatedBy);
            db.AddOutParameter(command, "CreatedDate", DbType.DateTime, 30);

            if (transaction == null)
            {
                db.ExecuteNonQuery(command);
            }
            else
            {
                db.ExecuteNonQuery(command, transaction);
            }

            partialHouse.CreatedDate = Convert.ToDateTime(db.GetParameterValue(command, "CreatedDate").ToString());
            partialHouse.UpdatedDate = partialHouse.CreatedDate;

            return true;
        }
开发者ID:nirshandileep,项目名称:RHP,代码行数:29,代码来源:PartialHouseDAO.cs

示例11: Insert

        public static bool Insert(SurveyEntity survey, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_SurveyInsert");

            db.AddInParameter(command, "MyUniversity", DbType.String, survey.MyUniversity);
            db.AddInParameter(command, "UniversityName", DbType.String, survey.UniversityName);
            db.AddInParameter(command, "UniversityAddress", DbType.String, survey.UniversityAddress);
            db.AddInParameter(command, "TypeOfResidence", DbType.String, survey.TypeOfResidence);
            db.AddInParameter(command, "TypeOfResidenceOption", DbType.String, survey.TypeOfResidenceOption);
            db.AddInParameter(command, "NameOfResidence", DbType.String, survey.NameOfResidence);
            db.AddInParameter(command, "AddressOfResidence", DbType.String, survey.AddressOfResidence);
            db.AddInParameter(command, "PropertyOwnerComment", DbType.String, survey.PropertyOwnerComment);
            db.AddInParameter(command, "Email", DbType.String, survey.Email);

            if (transaction == null)
            {
                db.ExecuteNonQuery(command);
            }
            else
            {
                db.ExecuteNonQuery(command, transaction);
            }

            return true;
        }
开发者ID:nirshandileep,项目名称:RHP,代码行数:25,代码来源:SurveyDAO.cs

示例12: Insert

        public bool Insert(StudentHouseLeave studentHouseLeave, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_StudentHouseLeaveInsert");

            db.AddInParameter(command, "HouseId", DbType.Guid, studentHouseLeave.HouseId);
            db.AddInParameter(command, "BaseHouseRoomId", DbType.Guid, studentHouseLeave.BaseHouseRoomId);
            db.AddInParameter(command, "RequestBy", DbType.Guid, studentHouseLeave.RequestBy);
            db.AddInParameter(command, "RequestTo", DbType.Guid, studentHouseLeave.RequestTo);
            db.AddInParameter(command, "status", DbType.Int16, studentHouseLeave.status);
            db.AddOutParameter(command, "RequestDate", DbType.DateTime, 30);

            if (transaction == null)
            {
                db.ExecuteNonQuery(command);
            }
            else
            {
                db.ExecuteNonQuery(command, transaction);
            }

            studentHouseLeave.RequestDate = Convert.ToDateTime(db.GetParameterValue(command, "RequestDate").ToString());
            studentHouseLeave.ResponseDate = studentHouseLeave.RequestDate;

            return true;
        }
开发者ID:nirshandileep,项目名称:RHP,代码行数:25,代码来源:StudentHouseLeaveDAO.cs

示例13: CreateStoredProcedures

        public static void CreateStoredProcedures(Database db)
        {
            DbCommand command;
            string sql;

            try
            {
                DeleteStoredProcedures(db);
            }
            catch { }

            sql = "CREATE OR REPLACE PACKAGE PKGENTLIB AS " +
                "TYPE T_CURSOR IS REF CURSOR; " +
                "PROCEDURE RegionSelect (CUR_OUT OUT T_CURSOR); " +
                "END PKGENTLIB;";

            command = db.GetSqlStringCommand(sql);
            db.ExecuteNonQuery(command);

            sql = "CREATE OR REPLACE PACKAGE BODY PKGENTLIB AS " +
                "PROCEDURE RegionSelect(CUR_OUT OUT T_CURSOR) IS " +
                "V_CURSOR T_CURSOR; " +
                "BEGIN " +
                "OPEN V_CURSOR FOR " +
                "SELECT * FROM Region ORDER BY RegionID; " +
                "CUR_OUT := V_CURSOR; " +
                "END RegionSelect; " +
                "END PKGENTLIB;";

            command = db.GetSqlStringCommand(sql);
            db.ExecuteNonQuery(command);

            sql = "create procedure RegionInsert (pRegionID IN Region.RegionID%TYPE, pRegionDescription IN Region.RegionDescription%TYPE) as " +
                    "BEGIN " +
                    "   insert into Region values(pRegionID, pRegionDescription); " +
                    "END;";

            command = db.GetSqlStringCommand(sql);
            db.ExecuteNonQuery(command);

            sql = "create procedure RegionUpdate (pRegionID IN Region.RegionID%TYPE, pRegionDescription IN Region.RegionDescription%TYPE) as " +
                    "BEGIN " +
                    "   update Region set RegionDescription = pRegionDescription where RegionID = pRegionID; " +
                    "END;";

            command = db.GetSqlStringCommand(sql);
            db.ExecuteNonQuery(command);

            sql = "create procedure RegionDelete (pRegionID IN Region.RegionID%TYPE) as " +
                    "BEGIN " +
                    "   delete from Region where RegionID = pRegionID; " +
                    "END;";

            command = db.GetSqlStringCommand(sql);
            db.ExecuteNonQuery(command);
        }
开发者ID:VAllens,项目名称:EntLibContrib.Data.Oracle.ManagedDataAccess,代码行数:56,代码来源:OracleDataSetHelper.cs

示例14: Delete

        public bool Delete(HouseOption house, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_HouseOptionDeleteByHouseId");
            db.AddInParameter(command, "HouseId", DbType.Guid, house.HouseId);

            if (transaction == null)
            {
                db.ExecuteNonQuery(command);
            }
            else
            {
                db.ExecuteNonQuery(command, transaction);
            }
            return true;
        }
开发者ID:nirshandileep,项目名称:RHP,代码行数:15,代码来源:HouseOptionDAO.cs

示例15: Delete

        public bool Delete(School school, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_SchoolDelete");
            db.AddInParameter(command, "SchoolId", DbType.Guid, school.SchoolId);
            db.AddInParameter(command, "UpdatedBy", DbType.Guid, school.UpdatedBy);

            if (transaction == null)
            {
                db.ExecuteNonQuery(command);
            }
            else
            {
                db.ExecuteNonQuery(command, transaction);
            }
            return true;
        }
开发者ID:nirshandileep,项目名称:RHP,代码行数:16,代码来源:SchoolDAO.cs


注:本文中的Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteNonQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。