Redian新闻
>
How to Call Stored Procedure in C# .Net?
avatar
How to Call Stored Procedure in C# .Net?# DotNet - 窗口里的风景
c*c
1
I am trying to use Stored Procedure and DataGrid. Do I need to use DataSet or
DataTable for binding?
Can someone provides some sample code or where can I get samples codes?
I am new on C# .Net. Thanks you for help
avatar
r*y
2

DataSet yes, DataTable no.
MSDN, or any books on ASP.NET/ADO.NET

【在 c***c 的大作中提到】
: I am trying to use Stored Procedure and DataGrid. Do I need to use DataSet or
: DataTable for binding?
: Can someone provides some sample code or where can I get samples codes?
: I am new on C# .Net. Thanks you for help

avatar
n*g
3
I always use DataTable or DataView as DataSource of DataGrid
very often.

【在 r****y 的大作中提到】
:
: DataSet yes, DataTable no.
: MSDN, or any books on ASP.NET/ADO.NET

avatar
r*y
4
DataTable is a collection od DataSet, and DataView is a kind of filter of
DataTable.
You can use whatever you like, I just mean "necessarily need".

【在 n*********g 的大作中提到】
: I always use DataTable or DataView as DataSource of DataGrid
: very often.

avatar
n*g
5

?????

【在 r****y 的大作中提到】
: DataTable is a collection od DataSet, and DataView is a kind of filter of
: DataTable.
: You can use whatever you like, I just mean "necessarily need".

avatar
d*r
6
???
反了吧。
Dataset has a collection of DataTable
avatar
r*y
7
我没说好。DataSet有俩Collection,一个是DataTable。结果说成DataTable is a
collection of DS了。应该说Tables is a property of DS. Tables is a
collection of DT.
DataGrid.DataSource = DS; DataGrid.DataMember="TableName";这样可以不用create
DT。
所以,可以只用DS;也可以只用DS和DV:
DV=new DV(DS.Tables["TbN"]); DG.DataSource=DV;
若不用DS,就要用SqlDataReader。除此之外的尽管补充。

【在 d*r 的大作中提到】
: ???
: 反了吧。
: Dataset has a collection of DataTable

avatar
d*r
8
当然可以了。
DS只是database的local immage。
真正起作用的是DT。
在你给的例子里,最后使用的还是DT。
??
你也说了,DT是在DS里面的,那为什么还要"create DT"呢?
如果只有一个DT的话,当然可以不用DS。
avatar
r*y
9
澄清一个定义:use DT,我的理解是create an obj of DT。如果说,是用到了DT的概念

那是没得说,非用不可的。这没什么可多说的。另外如果用了SqlDataAdapter,总得用
DS吧,无论几个DT。
我忘了一件事,可以不通过SqlDataAdapter,从而可以不用DS的,那就是用
SqlDataReader。这是捷径。

【在 d*r 的大作中提到】
: 当然可以了。
: DS只是database的local immage。
: 真正起作用的是DT。
: 在你给的例子里,最后使用的还是DT。
: ??
: 你也说了,DT是在DS里面的,那为什么还要"create DT"呢?
: 如果只有一个DT的话,当然可以不用DS。

avatar
k*i
10

Of course you can construct your datatable without using any dataset and use
it as the datasource. What's more, classes that implement the IList interface,
typed ilist interface, ibindinglist interface... can use as the binding
source.

【在 r****y 的大作中提到】
: 我没说好。DataSet有俩Collection,一个是DataTable。结果说成DataTable is a
: collection of DS了。应该说Tables is a property of DS. Tables is a
: collection of DT.
: DataGrid.DataSource = DS; DataGrid.DataMember="TableName";这样可以不用create
: DT。
: 所以,可以只用DS;也可以只用DS和DV:
: DV=new DV(DS.Tables["TbN"]); DG.DataSource=DV;
: 若不用DS,就要用SqlDataReader。除此之外的尽管补充。

avatar
r*y
11
Right. Then use SqlDataReader.

interface,

【在 k****i 的大作中提到】
:
: Of course you can construct your datatable without using any dataset and use
: it as the datasource. What's more, classes that implement the IList interface,
: typed ilist interface, ibindinglist interface... can use as the binding
: source.

avatar
n*g
12
ft, just you can just use datatable as source.
even you use ds, still it is using one of the datatable inside.

【在 r****y 的大作中提到】
: 我没说好。DataSet有俩Collection,一个是DataTable。结果说成DataTable is a
: collection of DS了。应该说Tables is a property of DS. Tables is a
: collection of DT.
: DataGrid.DataSource = DS; DataGrid.DataMember="TableName";这样可以不用create
: DT。
: 所以,可以只用DS;也可以只用DS和DV:
: DV=new DV(DS.Tables["TbN"]); DG.DataSource=DV;
: 若不用DS,就要用SqlDataReader。除此之外的尽管补充。

avatar
n*g
13
nod, I use an array of custom classes as datasouce to bind,
and you need implement IComprable to support datagrid sorting.

interface,

【在 k****i 的大作中提到】
:
: Of course you can construct your datatable without using any dataset and use
: it as the datasource. What's more, classes that implement the IList interface,
: typed ilist interface, ibindinglist interface... can use as the binding
: source.

avatar
r*y
14
说得对,我一个一个来。
我说的是不用DS就要用SqlDataReader。
不是“what could possibly be datasource of datagrid”.
至于什么可以做DG的DataSource:
For Windows Form DataGrid, following objs:
DataTable
DataView
DataSet
DataViewManager
Any component that implements the IListSource interface
Any component that implements the IList interface
For WebControl DataGrid, you can bind the Web Forms DataGrid to any object
that supports the IEnumerable interface.

【在 n*********g 的大作中提到】
: ft, just you can just use datatable as source.
: even you use ds, still it is using one of the datatable inside.

avatar
p*n
15
suggest you to use DAAB in the enterprise library
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/
daab.asp

or

【在 c***c 的大作中提到】
: I am trying to use Stored Procedure and DataGrid. Do I need to use DataSet or
: DataTable for binding?
: Can someone provides some sample code or where can I get samples codes?
: I am new on C# .Net. Thanks you for help

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。