从数据库中显示datagridview中的记录 [英] From database display the record in datagridview
问题描述
在数据库记录中如下
房间课程
1 AFF
2 MFA
3 REO
4 SAC
5 MFA
6 PST
7 RM
8 MC
i希望使用c#<如下所示在datagridview中显示记录br $>
房间课程房间课程
1 AFF 5 MFA
2 MFA 6 PST
3 REO 7 RM
4 SAC 8 MC
注意它是windows应用程序
Rgds,
Narasiman P
In database records as follows
Room Course
1 AFF
2 MFA
3 REO
4 SAC
5 MFA
6 PST
7 RM
8 MC
i want to display the record in datagridview as follows using c#
Room Course Room Course
1 AFF 5 MFA
2 MFA 6 PST
3 REO 7 RM
4 SAC 8 MC
Note it is windows application
Rgds,
Narasiman P
推荐答案
从数据集中划分记录并将其绑定到gridview是不可行的,更好地划分它在StoredProcedure中作为两列a nd将其返回给应用程序并捕获数据集中的数据并将其绑定到gridview。
存储过程将是
< br $>
its not feasible to divide the records from dataset and bind it to the gridview, better divide it in the StoredProcedure as two columns and return it to the application and catch the data in a dataset and bind it to the gridview.
the stored procedure will be
select d.*
into #temp_tab
from(
select
row_number() over(order by name) rno, User_Id,
name,
from TableName a inner join
select
a.User_ID ID,a.name NAME
from
(select row_number() over(order by name) new_rno ,* from #temp_tab where rno%2=1) a
left outer join (select row_number() over(order by name) new_rno ,* from #temp_tab where rno%2=0)
Drop table #temp_tab;
它会将记录分成两个列。
希望它有帮助
it will divide the records into two colummns.
Hope it helps
这篇关于从数据库中显示datagridview中的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!