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


C# DbHelper.ExcuteDatset方法代码示例

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


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

示例1: GetReaderGroup

        public ReaderGroup GetReaderGroup(int groupID)
        {
            try
            {
                using (var dbhelper = new DbHelper())
                {
                    // Fetch Reader Group
                    dbhelper.Command.CommandType = System.Data.CommandType.Text;
                    dbhelper.Command.CommandText = "SELECT [ReaderGroupID],[ReaderGroupName],[ReaderGroupDescription],[ReaderGroupLocation],[ReaderGroupZone] ,[ReaderDBConnectionString],[ReaderWCFConnectionString] FROM [RF].[ReaderGroup] WHERE [ReaderGroupID] = " + groupID.ToString();
                    DataSet ds = dbhelper.ExcuteDatset(dbhelper.Command);
                    if (ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                        throw new Exception("Reader Group not found for ID " + groupID);

                    ReaderGroup rdrGrp = DbHelper.DataTableToList<ReaderGroup>(ds.Tables[0]).FirstOrDefault();

                    // Fetch Readers
                    dbhelper.Command.CommandType = System.Data.CommandType.Text;
                    dbhelper.Command.CommandText = "SELECT [ReaderID],[ReaderGroupID],[ReaderTypeID],[ReaderName],[ReaderDescription],[IPAddress],[PortNo],[MACAddress],[AntennaPower],[ReaderPower],[LocationRef],[LocationDescription],[IsDeleted]  FROM [RF].[Reader] WHERE  [IsDeleted] = 0 AND [ReaderGroupID] = " + groupID.ToString();
                    DataSet dsReaders = dbhelper.ExcuteDatset(dbhelper.Command);

                    List<ReaderInfo> readersInfo = DbHelper.DataTableToList<ReaderInfo>(dsReaders.Tables[0]).ToList();
                    rdrGrp.Readers = readersInfo;

                    return rdrGrp;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:Systrics,项目名称:SystricsProjects,代码行数:31,代码来源:ReaderGroupDA.cs

示例2: GetAllReaderType

        public List<ReaderType> GetAllReaderType()
        {
            try
            {
                using (var dbhelper = new DbHelper())
                {
                    // Fetch Reader Group
                    dbhelper.Command.CommandType = System.Data.CommandType.Text;
                    dbhelper.Command.CommandText = "SELECT [ReaderTypeID],[ReaderTypeName],[ReaderTypeDescriotion],[ReaderTypeBL]  FROM [RF].[ReaderType]";
                    DataSet ds = dbhelper.ExcuteDatset(dbhelper.Command);
                    if (ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                        throw new Exception("Reader Type not found");

                    List<ReaderType> rdrGrpLst = DbHelper.DataTableToList<ReaderType>(ds.Tables[0]).ToList();

                    return rdrGrpLst;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:Systrics,项目名称:SystricsProjects,代码行数:23,代码来源:ReaderTypeDA.cs

示例3: GetReaderByReaderName

        public ResultObject GetReaderByReaderName(string readerName)
        {
            ResultObject objRes = new ResultObject();
            objRes.MethodInfo = "ReaderDA.GetReaderByReaderName ";
            try
            {
                using (var dbhelper = new DbHelper())
                {
                    // Fetch Reader Group
                    dbhelper.Command.CommandType = System.Data.CommandType.Text;
                    dbhelper.Command.CommandText = "SELECT [ReaderID],[ReaderGroupID],[ReaderTypeID],[ReaderName],[ReaderDescription],[IPAddress],[PortNo],[MACAddress],[AntennaPower],[ReaderPower],[LocationRef],[LocationDescription],[IsDeleted]  FROM [RF].[Reader] WHERE [ReaderName] = '" + readerName + "'";
                    DataSet dsReaders = dbhelper.ExcuteDatset(dbhelper.Command);

                    if (dsReaders.Tables.Count == 0 || dsReaders.Tables[0].Rows.Count == 0)
                    {
                        //throw new Exception("Reader not found");
                        objRes.IsSuccess = false;
                        objRes.ErrorMessage = "Reader not found";
                        objRes.ErrorMessageInternal = "Empty data table returned by DAL for supplied readerName = " + readerName;
                    }

                    List<ReaderInfo> readersInfo = DbHelper.DataTableToList<ReaderInfo>(dsReaders.Tables[0]).ToList();

                    objRes.IsSuccess = true;
                    objRes.ResultData["ReaderInfo"] = readersInfo.FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                objRes.IsSuccess = false;
                objRes.ErrorMessage = "Failed to get ReaderInfo from database on supplied readerName = " + readerName;
                objRes.ErrorMessageInternal = "Error : " + ex.ToString();
            }

            objRes.TimeStampString = DateTime.Now.ToString();
            return objRes;
        }
开发者ID:Systrics,项目名称:SystricsProjects,代码行数:37,代码来源:ReaderDA.cs


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