在网格视图中在运行时显示两个查询的数据 [英] show data of both queries at runtime in a grid view

查看:93
本文介绍了在网格视图中在运行时显示两个查询的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

selectQry = "select t2.tableName as 'Table Name',t2.gametype as 'Limit',Convert(varchar,Convert(numeric(18,2),t2.smallblind)) + '/' + Convert(varchar,Convert(numeric(18,2),t2.bigblind)) as 'Stakes',t3.GameName as 'Game Name'from tblgameinfo t1 join tblGameTables t2 on (t1.tableid=t2.tableid) join tblGames t3 on (t3.gameid = t1.gameid) where (t2.skinid= 6 or t2.skinid= 0) and t1.nickname = '" + nickname + "' order by nickname";





selectQry1 = "Select t2.tablename as'Table Name',t1.TableID as 'Table ID',t1.TournamentID as 'Tournament ID',t3.TournamentName'Tournament Name'from tblRegistration t1 join tblGameTables_TRMNT t2 on t1.TableID=t2.TableID join tblTournaments t3 on t3.tournamentID=t1.TournamentID where t3.skinid= " + SkinID + " and t1.nickname='" + nickname + "' AND t1.Eliminated='N' and t1.TableID >-1 and t3.State='P' and t3.TournamentType='S'";



这是两个sql查询..!这些工作正常,但现在我想在运行时在数据网格视图中显示两个查询的结果..!有不同的列名称,但我不需要在网格中显示它!在两个查询的网格视图中仅应显示数据.如果可以,是否可以给我解决方案...!

注意:=客户端需要在运行时一次在网格视图中显示两个查询的数据..!
谢谢...
Dnyanesh Wahiley



these are two sql queries..! these are working properly but now i want to show result of both queries at run time in data grid view..! there are different columns name but i dont need to show it in grid viev! only data shoud be displayed in grid view of both queries..! is that possible if yes pls give me a solution...!

Note:= client needs to show data of both quaries at runtime in a grid view in one single time..!
Thanking you...
Dnyanesh Wahiley

推荐答案

Trey This:

隐藏Gridview的columnName [
Trey This:

Hide columnName of Gridview[^]


嘿,
有可能创建临时数据表,并添加4个具有适当名称的列
并在临时表中添加两个表中的行,最后将其设置为该gridview的数据源.
祝您好运
Hey,
it''s possible create temporary Datatable add 4 columns with appropriate name
and add rows from both tables in temp table and finally set as datasourse of that gridview.
Best luck


您可以创建一个存储过程,并且可以在同一存储过程中声明一个表变量,可以将两个查询的结果集插入到该表变量中.
将数据插入表变量后,可以从表变量中选择记录.
用于向表变量声明和插入数据的代码段如下所示

You can create one stored procedure and in same stored procedure you can declare one table variable, you can insert result sets of both queries into this table variable.
After inserting data to your table variable you can select record from table variable.
Code snippet for declaring and inserting data to table variable is as below

DECLARE @ProductTotals TABLE
(
--Change your column name and type as per your need
  ProductID int,
  Revenue money
)
--Insert results of your first table
INSERT INTO @ProductTotals (ProductID, Revenue)
SELECT ProductID, SUM(UnitPrice * Quantity)
FROM OrderDetails1
GROUP BY ProductID
--Insert results of your second table 
INSERT INTO @ProductTotals (ProductID, Revenue)
SELECT ProductID, SUM(UnitPrice * Quantity)
FROM OrderDetails2
GROUP BY ProductID

--Last step to select data
SELECT * FROM @ProductTotals



此T-SQL代码段仅供您参考,请根据需要更改表变量的数据类型和列名称

希望这会帮助你.如果一切正常,请接受该解决方案,否则请通过您的查询回复我.
谢谢



This T-SQL code snippet is for your reference only, change your datatype and column name of table variable as per your need

Hope this will help you. If it works fine accept the solution otherwise revert back to me with your queries.
Thanks


这篇关于在网格视图中在运行时显示两个查询的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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