巨难!如何在sqlserver显示多数据集(10)

  • 主题发起人 主题发起人 青云
  • 开始时间 开始时间

青云

Unregistered / Unconfirmed
GUEST, unregistred user!
在sqlserver自带的ide工具Microsoft SQL Server Management Studio里;我们可以执行SQL: select 1 select 2就可以显示两个dbgrid,分别为1,2这个好像在Delphi里ado,dbExpress没法实现;有个空间叫SDAC 或者UniDAC可以用 uniQuery.OPen;获取第一个数据集,用UniQuery.OpenNext 获取下一个;不过不能一下子显示两个;于是我问了这家官方公司,它也没有好方法。我提问的邮件是:thank you very much!but I have no way to display multi-DataSet by One SQL at once.for example: uniQuery1.Sql.text:='select 1 select 2';I want to display it by Tdatasoucre + Tdbgrid;if execute: uniQuery1.open; then get '1' in dbgrid ;if execute :uniQuery1.openNext; then get '2' in dbgrid; but I noly can get one of them in dbgrid ;How can i get '1' and '2' in dbgrid1 and dbgrid2 together. I think we can do it by TClientDataSet + TDataSetProvider .but it's not a good way.I want do it by only UniDAC; In fact ,I am doing a IDE tools for mssql .I have finished a IDE tools for oracle like toad for oracle ,pl/sql developer etc. I know that :"Toad for sqlserver" And "Microsoft SQL Server Management Studio" can display multi-DataSet in multi-dbgrid by one Sql ;SO,I want to know witch way can do it! In Fact ,I think make a SQL TOOL Like Toad for mssql is difficult .for example :a Sql is : = ' update ... select ...update....exec procedure.. select ...'; if we want to execute it.we can not use UniQuery.open,because we do not know what is the sql(select ,update ,insert,exec procedure..etc.)we have to user " UniQuery.Execute " and then judge "UniQuery.IsQuery" to display dataset we execute ' update ... select ...update....exec procedure.. select ...' by " UniQuery.Execute " . it only can execute 'update ... select ...',UniQuery execute sql until get the first DataSet.we lost the next 'update....exec procedure.. select ...';SO ,I want to know witch way to Execute All sql in a multi-sql And Get all DataSet in DbGrids! I hope like this:------------------------------------------ var sSql:string; i:integer; begin sSql:='update...select...exec procedure..insert..select..'; uniquery1.sql.text:=sSql; uniquery1.ExecuteAll; for i:=0 to uniquery1.ExeCount-1 do begin if uniquery1.execute.IsQuery then begin datesource:=Tdatasource.create; datesource.name:='datesource'+inttostr(i); datesource.dataset:=uniquery1 dbgrid:=Tdbgrid.create; dbgrid.name:='dbgrid'+inttostr(i); dbgrid.datasoucre:=datesource; end else memo1.lines.add('uniquery1.RowsAffected is '+inttostr(uniquery1.RowsAffected )); end; end; 在2010-01-19 17:15:36,support <support@devart.com> 写道:>Hello.>>To get second dataset you should use the OpenNext method. But you can't open two datasets at once.>>Best regards,>Dmitry>Devart Team>www.devart.com>>>Ticket Details>===================>Ticket ID: 10164>Department: Dac Team>Priority: Medium>Status: On Hold
 
select 1 select 2 实际上还不是分部做的麽? 自己解析SQL语句 分部执行不就完了。。。。。。。如果满足一口吃两个馒头,你肯定会提出 巨难!如何一口吃四个馒头!!!!!
 
楼上的兄弟,以前在Oracle里,我也是分解的。分解难度很大,搞了几年;用了大量正则表达式技巧,勉强搞定。分隔符用;/判断;但是sqlserver与众不同;传入的SQL可以是多个,而且多个sql 可以不换行,可以不用分隔符";"之类。比如select ....declare @a varcharexec proc 123, @a output . --可能返回数据集select @a .update...select...go这么多语句有上下文变量关系,根本没法分成多个SQL,而这个SQL返回很多个数据集。该功能太难做了。因为我在写数据库的IDE工具,所以方方面面考虑的很多。
 
http://bbs.2ccc.com/topic.asp?topicid=347054
 
这样做有什么特别的目的吗?倒是可以把多个数据集拆出来显示:adoquery2.Recordset :=adoquery1.NextRecordset(1)
 
后退
顶部