.net DataTable 取值辅助类
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 取值辅助类的更多相关文章
- C#读取Excel,DataTable取值为空的解决办法
连接字符串这么些就行了 string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + opnFileName ...
- 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 ...
- js从后台无法取值问题
前台代码 <script type="text/javascript"> $(function () { var chart; $(document).ready(fu ...
- DataTbale取值
有一个DataTable数据 //创建DataTable对象 DataTable dt = new DataTable("Table_AX"); //为DataTable创建列 / ...
- QTP自动化测试-按行取值(win10下输入?问题)-笔记20181119
在win10下运行qtp10 所有输入汉字都会为?,在win7下可以.查询了百度.bingo没有解决问题.当前的解决办法 ,在脚本中使用DataTable取数据值,添加2行记录,一行使用汉字,一行使用 ...
- 如何解决流程开发中SheetRadioButtonList页面取值问题
分享一个常见的取值问题. 应用场景: SheetRadioButtonList控件,点击其中一项执行事件操作.如果是页面加载的情况下,值就无法取到. 具体原因如下: 我给SheetRadioButto ...
- jQuery radio的取值与赋值
取值: $("input[name='radioName']:checked").val(); 赋值: $("input[name='radioName'][value= ...
- python通过函数改变变量取值
严格讲应该是"通过函数调用,改变引用对象".python中,要区分"变量名"和"对象" 如果是类的对象,是引用类型的,那么可以通过函数调用, ...
- jsf初学selectOneMenu 绑定与取值
jsf 的selectOneMenu 最后生成的<select>标签.这里涉及到一个binding 起初一直不知道是干嘛的,后来参考了其他文章.就相当于在asp.net 中如:<as ...
随机推荐
- JY的题目(水)
JY的题目[问题背景]一天,JY觉得DZY智商太低下,决定和他离婚,除非DZY做出来她出的题目.DZY当然非常想和JY在一起,所以他只好又去请计算机大神WJC帮忙,WJC已经帮过他N多次忙了,不想再帮 ...
- 【MongoDB数据库】MongoDB 命令入门初探
MongoDB是一款NoSql数据库,使用了"面向集合"(Collection-Oriented)原理,意思是数据被分组存储在数据集中,被称为一个集合(Collection).每一 ...
- 一起学习iOS开发专用词汇,每天记3个,助你变大牛
大家做开发最大的问题是什么?英语的问题应该困扰很多的同学的地方,我们提倡科学学习开发中的常用词汇.我们不要求大家有特别好的听.说.写,只要能够记住,能够认识这些常用词汇你以后的开发也将游刃有余.我们的 ...
- SurfaceView 和 View 区别
android.view.View 和 android.view.SurfaceView SurfaceView 是从 View 基类中派生出来的显示类,直接子类有 GLSurfaceView和Vid ...
- 转 C#中静态方法与非静态方法区别比较
C#静态方法与非静态方法的区别不仅仅是概念上的,那么他们有什么具体的区别呢?让我们通过本文向你做一下解析. C#的类中可以包含两种方法:C#静态方法与非静态方法.那么他们的定义有什么不同呢?他们在使用 ...
- android入门——Activity(2)
主要内容:一.IntentFlag 二.简单复杂数据传递 三.数据回传 四.打开系统界面 五.IntentFilter匹配 一.IntentFlag 复制一段内容 来源 http://i ...
- VS2013无法链接到TFS (转)
VS2013无法链接到TFS(Visual studio online),错误TF31001,TF31002 TF31002: Unable to connect to VisualStudio ...
- C++学习之指针的常见错误
C++学习之指针的常见错误 我们在编程的过程中,有时候在使用指针的时候,删除一个指针以后一定要将这个指针设置为空指针,这是因为删除这个指针只是删除这个指针指向的地址,这个指针还真是的存在程 ...
- Cocos2dx游戏开发系列笔记13:一个横版拳击游戏Demo完结篇
懒骨头(http://blog.csdn.net/iamlazybone QQ:124774397 ) 写下这些东西的同时 旁边放了两部电影 周星驰的<还魂夜> 甄子丹的<特殊身份& ...
- fiddler--手机https
1.访问fiddler的主讲加端口,比如我的是:http://192.168.1.103:8080 在点击fiddlerroot certificate 下载安装证书即可