如何从数据表中读取数据? [英] How to read data from datatable?

查看:92
本文介绍了如何从数据表中读取数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我有一个存储过程,它返回Recordon执行.
我将结果保存到DATATABLE中.
然后,当我需要读取dataTable的字段时,请遵循以下代码:

Hi guys
I have a Store Procedure that return a Recordon execution.
I save the result into a DATATABLE.
Then when i need to read a field of the dataTable, i follow below code:

DataTable result;
result =DAL_Class.GetCustomerByID(C_ID);
Message.Show(Result.rows[0]["C_Name"].ToString());


推荐答案

it-discovery写道:
it-discovery wrote:

返回Recordon执行

return a Recordon execution





it-discovery写道:
it-discovery wrote:

Result.rows [0] ["C_Name"]

Result.rows[0]["C_Name"]



是的,根据您所说的,从数据表中检索字段的方式看起来不错.
尽管您可能只是在尝试使用ToString()转换之前检查它是否不为null.



Yes, based on what you say, the way to retrieve field from datatable looks fine.
Though you just might to check if it''s not null before trying to use ToString() conversion.


这篇关于如何从数据表中读取数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆