本文整理汇总了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;
}
}
示例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;
}
}
示例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;
}