在sql1链接数据库sql2,sql1中存储过程调用了sql2,用delphi的storedproc调用存储过程出错Heterogenous queries require the ansi_nulls an

prosectinfo 2004-10-27 09:24:24
1。 sql1链接接数据库sql2,
2。 用sa登陆sql2
3。 创建存储过程
set ansi_nulls on
set ansi_warnings on

CREATE PROCEDURE [dbo].[GetCwMaxMinYear]
AS
begin
Select Min(Convert(int,substring(name,12,4))) as minyear,
Max(Convert(int,substring(name,12,4))) as maxyear
From [sql2].master.dbo.sysdatabases Where substring(name,1,10)='UFDATA_005'
end
GO

set ansi_nulls off
set ansi_warnings off
存储过程在查询分析其中正确执行
delphi用bde方式storedproc控件访问这个储存过程,出现
"Heterogenous queries require the ansi_nulls and ansi_warnings for the connection..."
但用ado方式和adostoredproc就能正确访问
请问有谁碰到这样的问题?

...全文
140 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
prosectinfo 2004-10-27
  • 打赏
  • 举报
回复
谢谢你的回答 ,但是我试过了,是不行的,把储存过程改成

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


ALTER PROCEDURE [dbo].[GetDBNames]
AS
begin
Select name From [ky].master.dbo.sysdatabases
end

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
在ado连接方式是可以的,但在bde下是报错的
“Heterogenous queries require the ansi_nulls and ansi_warnings for the connection..."
xhh_88 2004-10-27
  • 打赏
  • 举报
回复
上面的[ky]是我建的连接服务器的名称
xhh_88 2004-10-27
  • 打赏
  • 举报
回复
你的create procdure 前没有GO你的语句在查询分析器里能通过吗??
xhh_88 2004-10-27
  • 打赏
  • 举报
回复
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


ALTER PROCEDURE [dbo].[GetCwMaxMinYear]
AS
begin

Select Min(Convert(int,substring(name,12,4))) as minyear,
Max(Convert(int,substring(name,12,4))) as maxyear
From [ky].master.dbo.sysdatabases Where substring(name,1,10)='UFDATA_005'
end

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO


///建了一个odbc后,用BDE的控件连接,执行存储过程没有问题.
prosectinfo 2004-10-27
  • 打赏
  • 举报
回复
to xhh_88(三友)
链接数据库时必须设置:
set ansi_nulls on
set ansi_warnings on
xhh_88 2004-10-27
  • 打赏
  • 举报
回复
前两句与你步一样,我把 ansi_nulls ,ansi_warnings 一开始就关了!

错误提示里,就是指这里有问题.
prosectinfo 2004-10-27
  • 打赏
  • 举报
回复
什么意思?我不就是这样做的吗?
xhh_88 2004-10-27
  • 打赏
  • 举报
回复
set ansi_nulls off
set ansi_warnings off

CREATE PROCEDURE [dbo].[GetCwMaxMinYear]
AS
begin
Select Min(Convert(int,substring(name,12,4))) as minyear,
Max(Convert(int,substring(name,12,4))) as maxyear
From [sql2].master.dbo.sysdatabases Where substring(name,1,10)='UFDATA_005'
end
GO

set ansi_nulls off
set ansi_warnings off
prosectinfo 2004-10-27
  • 打赏
  • 举报
回复
我必须通过bde方式连接数据库,我做的是二次开发
prosectinfo 2004-10-27
  • 打赏
  • 举报
回复
可以了,在本地数据库和连结数据库中要设置(但用ado不需要,可能是因为sqlserver和ado都是Microsoft 的原因)
sp_dboption 'sql1','ANSI warnings','on'
go
sp_dboption 'sql1','ANSI nulls','on'
go
sp_dboption 'sql2','ANSI warnings','on'
go
sp_dboption 'sql2','ANSI nulls','on'
go
只是在创建储存过程的时候
set ansi_nulls on 和
set ansi_warnigs on 还不行

xhh_88 2004-10-27
  • 打赏
  • 举报
回复
我建了一个ODBC,然后用BDE组件组下的stroedproc控件连接没有问题.
我的存储过程,就是上面我发的那个.
prosectinfo 2004-10-27
  • 打赏
  • 举报
回复
xhh_88(三友)
我是这样的,你那边可以吗?ado方式连结用adostoredproc是可以得,但bde的stroedproc就有错
xhh_88 2004-10-27
  • 打赏
  • 举报
回复
1:如果你的过程只要这个查询,应该不会出现这个错误,你的过程中exec语句?
2:重建你的ODBC连接,新建工程单独调用看看!

2,496

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧