Hi,
I have problem with TMSQuery.Open x Execute. I have for example this script:
DBCC CHECKDB (MyTestDB) WITH NO_INFOMSGS, TABLERESULTS
or
IF OBJECT_ID('dbo.ep_DF01','P')IS NOT NULL
BEGIN
EXEC dbo.ep_DF01 1, 'xxx', 2 -- it returns some SELECT
END
In both cases I need to run script with Open, because I expected result set in some cases. But it is possible that it will return no result set and it such case I get error message 'Query must return exactly one result set - use Execute'. I need to call Open and I cannot check all my scripts in the whole application (~2.000.000 rows).
What I can do it? Our old component for SQL Server said RecordCount = 0 (or IsEmpty = True) in case to return no result set...
Thanks a lot
Roman
Open without result set
Open without result set
I found that problem is in unit OLEDBAccess in
The comment says that constant SNoResultSet is used in other place but I found it in unit MSConsts only (and in OLEDBAccess of cause).
If I change source code to
all works OK (I didn't get any error yet). Can I do it? Or it is bad solution?
SDAC 4.70.0.44
Thanks
Roman
Code: Select all
function TOLEDBRecordSet.Fetch(FetchBack: boolean = False): boolean;
...
begin
...
try
if Fields.Count = 0 then
DatabaseError(SNoResultSet, nil); /// Warning - constant SNoResultSet used for detecting in TCustomMSDataSet.OpenNext
...
end;
If I change source code to
Code: Select all
if Fields.Count = 0 then Exit;SDAC 4.70.0.44
Thanks
Roman