DataTableCommon类主要是帮助取值

方法列表:

public static string GetCellString(DataTable dt,int row, int column)

public static string GetCellString(DataTable dt,int row, string columnName)

public static int GetCellInt(DataTable dt, int row, int column)

public static int GetCellInt(DataTable dt, int row, string columnName)

public static decimal GetCellDecimal(DataTable dt, int row, int column)

public static decimal GetCellDecimal(DataTable dt, int row,string columnName)

 public class DataTableComon
{
#region DataTable 取值 public static string GetCellString(DataTable dt, int row, int column)
{
string strValue = string.Empty;
try
{
if (dt == null || dt.Rows.Count == )
return null;
object objValue = dt.Rows[row][column];
if (objValue == null || Convert.IsDBNull(objValue))
return null;
strValue = objValue.ToString();
}
catch (Exception)
{
}
return strValue;
}
public static string GetCellString(DataTable dt, int row, string columnName)
{
string strValue = string.Empty;
try
{
if (dataRow == null || dataRow.Rows.Count == )
return null;
object objValue = dataRow.Rows[row][columnName];
if (objValue == null || Convert.IsDBNull(objValue))
return null;
strValue = objValue.ToString();
}
catch (Exception)
{
}
return strValue;
}
public static int GetCellInt(DataTable dt, int row, int column)
{
int intValue = ;
try
{
if (dt == null || dt.Rows.Count == )
return ;
object objValue = dt.Rows[row][column];
if (objValue == null || Convert.IsDBNull(objValue))
return ;
intValue = Convert.ToInt32(objValue);
}
catch (Exception)
{
}
return intValue;
}
public static int GetCellInt(DataTable dt, int row, string columnName)
{
int intValue = ;
try
{
if (dt == null || dt.Rows.Count == )
return ;
object objValue = dt.Rows[row][columnName];
if (objValue == null || Convert.IsDBNull(objValue))
return ;
intValue = Convert.ToInt32(objValue);
}
catch (Exception)
{
}
return intValue;
} public static decimal GetCellDecimal(DataTable dt, int row, int column)
{
decimal intValue = ;
try
{
if (dt == null || dt.Rows.Count == )
return ;
object objValue = dt.Rows[row][column];
if (objValue == null || Convert.IsDBNull(objValue))
return ;
intValue = Convert.ToDecimal(objValue);
}
catch (Exception)
{
}
return intValue;
}
public static decimal GetCellDecimal(DataTable dt, int row, string columnName)
{
decimal intValue = ;
try
{
if (dt == null || dt.Rows.Count == )
return ;
object objValue = dt.Rows[row][columnName];
if (objValue == null || Convert.IsDBNull(objValue))
return ;
intValue = Convert.ToDecimal(objValue);
}
catch (Exception)
{
}
return intValue;
} #endregion #region DataRow 取值 public static string GetCellString(DataRow dataRow, int column)
{
string strValue = string.Empty;
try
{
if (dataRow == null)
return null;
object objValue = dataRow[column];
if (objValue == null || Convert.IsDBNull(objValue))
return null;
strValue = objValue.ToString();
}
catch (Exception)
{
}
return strValue;
}
public static string GetCellString(DataRow dataRow,string columnName)
{
string strValue = string.Empty;
try
{
if (dataRow == null)
return null;
object objValue = dataRow[columnName];
if (objValue == null || Convert.IsDBNull(objValue))
return null;
strValue = objValue.ToString();
}
catch (Exception)
{
}
return strValue;
}
public static int GetCellInt(DataRow dataRow, int column)
{
int intValue = ;
try
{
if (dataRow == null )
return ;
object objValue = dataRow[column];
if (objValue == null || Convert.IsDBNull(objValue))
return ;
intValue = Convert.ToInt32(objValue);
}
catch (Exception)
{
}
return intValue;
}
public static int GetCellInt(DataRow dataRow, string columnName)
{
int intValue = ;
try
{
if (dataRow == null)
return ;
object objValue = dataRow[columnName];
if (objValue == null || Convert.IsDBNull(objValue))
return ;
intValue = Convert.ToInt32(objValue);
}
catch (Exception)
{
}
return intValue;
} public static decimal GetCellDecimal(DataRow dataRow,int column)
{
decimal intValue = ;
try
{
if (dataRow == null )
return ;
object objValue = dataRow[column];
if (objValue == null || Convert.IsDBNull(objValue))
return ;
intValue = Convert.ToDecimal(objValue);
}
catch (Exception)
{
}
return intValue;
}
public static decimal GetCellDecimal(DataRow dataRow, string columnName)
{
decimal intValue = ;
try
{
if (dataRow == null)
return ;
object objValue = dataRow[columnName];
if (objValue == null || Convert.IsDBNull(objValue))
return ;
intValue = Convert.ToDecimal(objValue);
}
catch (Exception)
{
}
return intValue;
} #endregion
}

.net DataTable 取值辅助类的更多相关文章

  1. C#读取Excel,DataTable取值为空的解决办法

    连接字符串这么些就行了 string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + opnFileName ...

  2. SELECT INTO和INSERT INTO SELECT的区别 类似aaa?a=1&b=2&c=3&d=4,如何将问号以后的数据变为键值对 C# 获取一定区间的随即数 0、1两个值除随机数以外的取值方法(0、1两个值被取值的概率相等) C# MD5 加密,解密 C#中DataTable删除多条数据

    SELECT INTO和INSERT INTO SELECT的区别   数据库中的数据复制备份 SELECT INTO: 形式: SELECT value1,value2,value3 INTO Ta ...

  3. js从后台无法取值问题

    前台代码 <script type="text/javascript"> $(function () { var chart; $(document).ready(fu ...

  4. DataTbale取值

    有一个DataTable数据 //创建DataTable对象 DataTable dt = new DataTable("Table_AX"); //为DataTable创建列 / ...

  5. QTP自动化测试-按行取值(win10下输入?问题)-笔记20181119

    在win10下运行qtp10 所有输入汉字都会为?,在win7下可以.查询了百度.bingo没有解决问题.当前的解决办法 ,在脚本中使用DataTable取数据值,添加2行记录,一行使用汉字,一行使用 ...

  6. 如何解决流程开发中SheetRadioButtonList页面取值问题

    分享一个常见的取值问题. 应用场景: SheetRadioButtonList控件,点击其中一项执行事件操作.如果是页面加载的情况下,值就无法取到. 具体原因如下: 我给SheetRadioButto ...

  7. jQuery radio的取值与赋值

    取值: $("input[name='radioName']:checked").val(); 赋值: $("input[name='radioName'][value= ...

  8. python通过函数改变变量取值

    严格讲应该是"通过函数调用,改变引用对象".python中,要区分"变量名"和"对象" 如果是类的对象,是引用类型的,那么可以通过函数调用, ...

  9. jsf初学selectOneMenu 绑定与取值

    jsf 的selectOneMenu 最后生成的<select>标签.这里涉及到一个binding 起初一直不知道是干嘛的,后来参考了其他文章.就相当于在asp.net 中如:<as ...

随机推荐

  1. Android图片裁剪之自由裁剪

    我的博客http://blog.csdn.net/dawn_moon 客户的需求都是非常怪的.我有时候在给客户做项目的时候就想骂客户是sb.可是请你相信我,等你有需求,自己变成客户的时候,给你做项目的 ...

  2. Android SQLite 事务处理

    应用程序初始化时需要批量的向sqlite中插入大量数据,单独的使用for+Insert方法导致应用响应缓慢,因为 sqlite插入数据的时候默认一条语句就是一个事务,有多少条数据就有多少次磁盘操作.我 ...

  3. AJAX - 创建 XMLHttpRequest 对象

    XMLHttpRequest 是 AJAX 的基础. XMLHttpRequest 对象 所有现代浏览器均支持 XMLHttpRequest 对象(IE5 和 IE6 使用 ActiveXObject ...

  4. C++ 文件操作实例

    图1 文件个数及名称 图2 文件内容 背景:如图1所示,现有9个要处理的文件,每个文件的内容格式如图2所示,仅仅只是数值部分不同. 问题:如何提取每个文件中的相同属性的数值到同一个文件中? 输出示例: ...

  5. appium locator

    If you want to find out more about the UIAutomator library, then it might be helpful to check out ht ...

  6. 如何调试webservice接口是否正常

    soapui 调试webservice接口 1首先iis 部署网站 2添加webservice 3附加到进程调试  找w开头的 4然后request填充数据

  7. FlashFXP使用教程

    点FlashFXP菜单栏“站点-站点管理”打开站点管理器.然后点新建站点,输入站点名称(随意),确定.   编辑站点管理器里新建的站点的相关信息,包括站点名称.地址.用户名称.密码等.编辑完成,点应用 ...

  8. powerdesigener 12.5注册机

    下载链接 下载链接 密码:awg9

  9. C++链接库

    静态链接库在程序编译链接过程中就导入lib文件并且包含在生成的exe文件里,而动态链接库DLL是在程序运行中由程序加载和卸载的,也就是说它是动态的,当然动态链接库DLL也可以静态加载当做静态来用: 静 ...

  10. mysql中中文字符串的截取

    SET NAMES 'utf8'; SET v_length = character_length(citys); SET citys = left(citys COLLATE utf8_bin, v ...