MS SQL을 사용하여 여러 저장 프로 시저를 실행했습니다. MS SQL Server Management Studio에서 프로 시저를 실행하면 항상 열 머리글이 반환됩니다. Delphi 프로그램에서도이 기능을 사용하려고합니다. 현재 데이터 세트에 행이없는 경우 헤더가 리턴되지 않습니다. 델파이 7, TADOStoredProc, TADODataset 및 문자열 그리드 사용 :Delphi ADOStoredProc로 빈 결과 집합에서 열 헤더 가져 오기
ADOStoredProc1.ObjectView := True;
ADOStoredProc1.Open;
ADODataSet1.Recordset := ADOStoredProc1.Recordset;
// process the first dataset, which contains rows
if not ADODataSet1.IsEmpty then
begin
AdvGridWorkbook1.ActiveSheet := 0;
// build grid header
SetupHeader;
// build grid detail
SetupDetail;
end
else
begin
Memo1.Lines.Add('Returned empty data set for Mapping');
end;
// load the next dataset. no data rows but MS Studio shows column headers
ADODataSet1.Recordset := ADOStoredProc1.NextRecordset(RecordsAffected);
if not ADODataSet1.IsEmpty then // tests as empty
begin
AdvGridWorkbook1.ActiveSheet := 1;
// build grid header - none are returned as IsEmpty = True
SetupHeader;
// build grid detail
SetupDetail;
end
else
begin
// this message is added to my memo field.
Memo1.Lines.Add('Returned empty data set for Labor');
end;
ADODataSet1.Close;
ADOStoredProc1.Close;
사람이 MS에 열 머리글이 돌아오고있어 얼마나 알고 있나요?
저장된 프로 시저이다는 열 헤더에 포함되지 않도록, 데이터를 포함하는 실제 레코드
USE [NG_Test]
GO
/****** Object: StoredProcedure [dbo].[NG_Checks] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[NG_Checks]
@fiscal_month_year nvarchar(50)
AS
BEGIN
declare @production_date datetime
declare @start_date datetime
declare @end_date datetime
select @production_date = ng_production_release_date
from ng_common_global_provisioning
select @start_date = start_date, @end_date = end_date
from ng_common_accounting_fiscal_month
where fiscal_month_year = @fiscal_month_year
-- this is the 1st dataset returned
select b.company, b.wo_type, b.wo_code
from ng_accounting_mapping_ng_wo_2_gp b
where wo_code not in (select wo_code from ng_wo_codes a)
-- this is the 2nd dataset returned
select a.wo_display_id, a.wo_code, a.labor_revenue, a.labor_cost,
a.create_date, a.completion_date, a.finalizing_date, a.wo_status
from ng_wo_header a, ng_wo_labor_rates b
where a.wo_code = b.work_order_code
and a.company = b.company
and a.wo_type = b.work_order_type
and a.wo_type in ('RO', 'BS')
and a.labor_revenue is not null and a.labor_revenue <> 0
and a.labor_cost is not null and a.labor_cost <> 0
and a.create_date > @start_date
and a.create_date < @end_date
and a.create_date > @production_date
END
확인, 모르겠지만, IsEmpty 함수에 대한 테스트를 제거하고 그리드는 이제 헤더를 표시합니다! 그것은 저에게 데이터가 있다는 것을 나에게 알려주지 만 (칼럼 헤더), 빈 것으로 테스트합니다. 나는 "빈"이란 행이 아니라 실제 정보가 부족한 것을 의미한다고 생각합니다. – worker17
당신이 말한대로! 참조에서 ['IsEmpty'] (http://docwiki.embarcadero.com/Libraries/XE2/en/Data.DB.TDataSet.IsEmpty)는 데이터 집합에 레코드가 없는지 여부를 나타냅니다. 따라서 필드 이름이 아닌 데이터 집합 행에만 적용됩니다. 어쨌든, 당신은 문제를 해결 했으므로 공평하게 게시하고 [자신의 대답을 수락합니다] (http://blog.stackoverflow.com/2009/01/accept-your-own-answers/). 장래 방문자가 동일한 문제에 대한 답을 빨리 찾을 때 도움이 될 수 있습니다. 감사! – TLama