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


C# Database.ExecuteScalar方法代码示例

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


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

示例1: Insert

        protected int Insert(BaseTable nesne, DbCommand dbComm, DbTransaction dbTransaction, Database db)
        {
            //YetkiKullanici ui = (YetkiKullanici)HttpContext.Current.Session["YetkiKullanici"];
            //if (ui == null)
            //{
            //    ui = new YetkiKullanici();
            //    ui.Tckimlikno = "Everyone";
            //    ui.Ip = HttpContext.Current.Request.UserHostAddress;
            //}

            int sonuc = 0;
            string geriDeger = "";
            if (dbTransaction == null) geriDeger = db.ExecuteScalar(dbComm).ToString();
            else geriDeger = db.ExecuteScalar(dbComm, dbTransaction).ToString();
            //if (ConfigurationSettings.AppSettings.Get("DBLOG_AKTIF") != null &&
            //    ConfigurationSettings.AppSettings.Get("DBLOG_AKTIF") == "E")
            //{
            //    try
            //    {
            //        int.TryParse(geriDeger, out sonuc);
            //        GenDbLog log = new GenDbLog();
            //        log.Tckimlikno = ui.Tckimlikno;
            //        log.KullaniciIp = ui.Ip;
            //        log.Tablo = nesne.GetName();
            //        log.KayitId = sonuc;
            //        log.Kayit = nesne.ToString();
            //        log.Tarih = DateTime.Now;
            //        log.YapilanIslem = "I";
            //        InsertLog(log, dbTransaction, db);
            //    }
            //    catch (Exception ex) { }
            //}
            bool snc = int.TryParse(geriDeger, out sonuc);
            return sonuc;
        }
开发者ID:bahattinz,项目名称:SeminerKayit-1,代码行数:35,代码来源:BaseDbDao.cs

示例2: Insert

        public static int Insert(Database db, CapturePicture ocapturePicture)
        {
            StringBuilder sbField = new StringBuilder();
            StringBuilder sbValue = new StringBuilder();
            sbField.Append("INSERT INTO  [CapturePicture](");
            sbValue.Append("values (");
            //sbField.Append("[PictureID]");
            //sbValue.AppendFormat("'{0}'", ocapturePicture.PictureID);
            sbField.Append("[CameraID]");
            sbValue.AppendFormat("{0}", ocapturePicture.CameraID);
            sbField.Append(",[Datetime]");
            //sbValue.AppendFormat(",'{0}'", ocapturePicture.Datetime);
            sbValue.AppendFormat(",'{0}'", ocapturePicture.Datetime);
            sbField.Append(",[FilePath])");
            sbValue.AppendFormat(",'{0}')", ocapturePicture.FilePath);

            string cmdText = sbField.ToString() + " " + sbValue.ToString();

            try
            {
                cmdText = cmdText.Replace("\r\n", "");
                db.ExecuteNonQuery(CommandType.Text, cmdText);
                //string cmdText2 = "select max(PictureID) from CapturePicture";
                //return int.Parse(db.ExecuteScalar(CommandType.Text, cmdText2).ToString());
                int id = int.Parse(db.ExecuteScalar(CommandType.Text, "SELECT     ident_current('CapturePicture')").ToString());
                return id;
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
开发者ID:dalinhuang,项目名称:intvideosurv,代码行数:33,代码来源:CapturePictureDataAccess.cs

示例3: Insert

        public static int Insert(Database db, REct oRect)
        {
            StringBuilder sbField = new StringBuilder();
            StringBuilder sbValue = new StringBuilder();
            sbField.Append("INSERT INTO  [REct](");
            sbValue.Append("values (");
            //sbField.Append("[RectID]");
            //sbValue.AppendFormat("'{0}'", oRect.RectID);
            sbField.Append("[X]");
            sbValue.AppendFormat("{0}", oRect.X);
            sbField.Append(",[Y]");
            sbValue.AppendFormat(",{0}", oRect.Y);
            sbField.Append(",[W]");
            sbValue.AppendFormat(",{0}", oRect.W);
            sbField.Append(",[H])");
            sbValue.AppendFormat(",{0})", oRect.H);
            string cmdText = sbField.ToString() + " " + sbValue.ToString();

            try
            {
                cmdText = cmdText.Replace("\r\n", "");
                db.ExecuteNonQuery(CommandType.Text, cmdText);
                int id = int.Parse(db.ExecuteScalar(CommandType.Text, "SELECT     ident_current('REct')").ToString());
                return id;
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
开发者ID:dalinhuang,项目名称:intvideosurv,代码行数:31,代码来源:REctDataAccess.cs

示例4: Insert

        public static int Insert(Database db, Track oTrack)
        {
            StringBuilder sbField = new StringBuilder();
            StringBuilder sbValue = new StringBuilder();
            sbField.Append("INSERT INTO  [Track](");
            sbValue.Append("values (");
            //sbField.Append("[Id]");
            //sbValue.AppendFormat("'{0}'", oTrack.Id);
            sbField.Append("[REct])");
            sbValue.AppendFormat("'{0}')", oTrack.REct);
            string cmdText = sbField.ToString() + " " + sbValue.ToString();

            try
            {
                cmdText = cmdText.Replace("\r\n", "");
                db.ExecuteNonQuery(CommandType.Text, cmdText);
                int id = int.Parse(db.ExecuteScalar(CommandType.Text, "SELECT     ident_current('Track')").ToString());
                return id;
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
开发者ID:dalinhuang,项目名称:intvideosurv,代码行数:25,代码来源:TrackDataAccess.cs

示例5: Insert

        public static int Insert(Database db, EventRect oEventRect)
        {
            StringBuilder sbField = new StringBuilder();
            StringBuilder sbValue = new StringBuilder();
            sbField.Append("INSERT INTO  [EvenRectInfo](");
            sbValue.Append("values (");
            //sbField.Append("[FaceID]");
            //sbValue.AppendFormat("'{0}'", oFace.FaceID);
            sbField.Append("[x]");
            sbValue.AppendFormat("{0}", oEventRect.x);
            sbField.Append(",[y]");
            sbValue.AppendFormat(",{0}", oEventRect.y);
            sbField.Append(",[w]");
            sbValue.AppendFormat(",{0}", oEventRect.w);
            sbField.Append(",[h]");
            sbValue.AppendFormat(",{0}", oEventRect.h);
            sbField.Append(",[ObjectId])");
            sbValue.AppendFormat(",{0})", oEventRect.ObjectId);
            string cmdText = sbField.ToString() + " " + sbValue.ToString();

            try
            {
                cmdText = cmdText.Replace("\r\n", "");
                db.ExecuteNonQuery(CommandType.Text, cmdText);
                int id = int.Parse(db.ExecuteScalar(CommandType.Text, "SELECT     ident_current('EventRectInfo')").ToString());
                return id;
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
开发者ID:dalinhuang,项目名称:intvideosurv,代码行数:33,代码来源:EventRectDataAccess.cs

示例6: IsExistRow

        private static bool IsExistRow(Database db,string name)
        {
            string cmdText = string.Format("select count(*) from systemParameter where Name='{0}';", name);
            try
            {
                return int.Parse(db.ExecuteScalar(CommandType.Text, cmdText).ToString())>0;

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
开发者ID:dalinhuang,项目名称:intvideosurv,代码行数:14,代码来源:SystemParametersDataAccess.cs

示例7: GetMaxDisplayChannelId

        public static int GetMaxDisplayChannelId(Database db)
        {
            string cmdText = "select max(DisplayChannelId) from displayChannelInfo";
            try
            {
                return int.Parse(db.ExecuteScalar(CommandType.Text, cmdText).ToString());

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
开发者ID:dalinhuang,项目名称:intvideosurv,代码行数:14,代码来源:DisplayChannelDataAccess.cs

示例8: IsTaskExisted

        public static bool IsTaskExisted(Database db, int taskId)
        {
            string cmdText = string.Format("select count(*) from TaskInfo where TaskId={0}",taskId);
            try
            {
                return int.Parse(db.ExecuteScalar(CommandType.Text, cmdText).ToString())>0;

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
开发者ID:dalinhuang,项目名称:intvideosurv,代码行数:14,代码来源:TaskDataAccess.cs

示例9: IsExistCapturePicture

        public static bool IsExistCapturePicture(Database db, int id, DateTime dt)
        {
            string cmdText = string.Format("select count(*) from CapturePicture where CameraID={0} and Datetime={1}", id, dt);
            try
            {
                return int.Parse(db.ExecuteScalar(CommandType.Text, cmdText).ToString()) > 0;

            }
            catch (Exception ex)
            {

                return false;
            }
        }
开发者ID:dalinhuang,项目名称:intvideosurv,代码行数:14,代码来源:CapturePictureDataAccess.cs

示例10: GetMaxGroupSwitchGroupId

        public static int GetMaxGroupSwitchGroupId(Database db)
        {
            string cmdText = "select max(Id) from GroupSwitchGroup";
            try
            {
                return int.Parse(db.ExecuteScalar(CommandType.Text, cmdText).ToString());

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
开发者ID:dalinhuang,项目名称:intvideosurv,代码行数:14,代码来源:GroupSwitchGroupDataAccess.cs

示例11: GetMaxSystemLogId

        public static int GetMaxSystemLogId(Database db)
        {
            string cmdText = "select max(Id) from OperateLog";
            try
            {
                return int.Parse(db.ExecuteScalar(CommandType.Text, cmdText).ToString());

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
开发者ID:dalinhuang,项目名称:intvideosurv,代码行数:14,代码来源:OperateLogDataAccess.cs

示例12: GetMaxUserId

        public static int GetMaxUserId(Database db)
        {
            string cmdText = "select max([UserId]) from [UserInfo]";
            try
            {
                return int.Parse(db.ExecuteScalar(CommandType.Text, cmdText).ToString());

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
开发者ID:dalinhuang,项目名称:intvideosurv,代码行数:14,代码来源:UserDataAccess.cs

示例13: GetCurrentDateTime

 internal static DateTime GetCurrentDateTime(Database db)
 {
     try
       {
     using (DbCommand cmd = db.GetSqlStringCommand(Resources.GetDatabaseCurrentDateTime))
     {
       return (DateTime)db.ExecuteScalar(cmd);
     }
       }
       catch (Exception e)
       {
     AssistLogger.Log<ExceptionHolder>(e);
     return DateTime.Now;
       }
 }
开发者ID:popovegor,项目名称:gt,代码行数:15,代码来源:DBUtils.cs

示例14: GetEventRectCustomQuantity

        public static int GetEventRectCustomQuantity(Database db, int objectid)
        {
            string cmdText = string.Format(
                "select count(distinct EventRectInfo.EventRectId) " +
                "from EventRectInfo " +
                "where EventRectInfo.ObjectId={0}",objectid);
            try
            {
                return int.Parse(db.ExecuteScalar(CommandType.Text, cmdText).ToString());
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
开发者ID:dalinhuang,项目名称:intvideosurv,代码行数:16,代码来源:EventRectDataAccess.cs

示例15: GetEventCustomQuantity

        public static int GetEventCustomQuantity(Database db, string str)
        {
            str = str.Replace("''", "'");
            string cmdText = string.Format(
                "select count(distinct EventInfo.EventId) " +
                "from EventInfo,CapturePicture,VideoInfo " +
                "where EventInfo.PictureId=CapturePicture.PictureId and " +
                "CapturePicture.CameraId = VideoInfo.CameraId and (CapturePicture.[DateTime] between VideoInfo.CaptureTimeBegin and VideoInfo.CaptureTimeEnd) {0};", str);
            try
            {
                return int.Parse(db.ExecuteScalar(CommandType.Text, cmdText).ToString());
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
开发者ID:dalinhuang,项目名称:intvideosurv,代码行数:18,代码来源:EventDataAccess.cs


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