用程序更新存取过程 ( 积分: 100 )

  • 主题发起人 主题发起人 louqing_2
  • 开始时间 开始时间
L

louqing_2

Unregistered / Unconfirmed
GUEST, unregistred user!
怎么用ADOQUERY来建立存取过程,能与查询分析器一样?
如我有存取过程:
if exists (SELECT id FROM sysobjects
WHERE (id = OBJECT_ID(N'Myp2')) AND (OBJECTPROPERTY(id, N'IsProcedure') = 1))
drop PROCEDURE Myp2
go
CREATE PROCEDURE Myp2;1
@v_rkey int
with encryption
AS
begin
.....
end
go
CREATE PROCEDURE Myp2;2
@v_rkey int
with encryption
AS
begin
.....
end
go
.....

我用如下的:
s := ////上面的SQL
...
dm.ADOQALL2.sql.text := s ;
...
dm.ADOQALL2.execsql; //运行时报错,我要怎么做?
 
有没有哪位知道的啊,急啊
 
简单方法:把adoquery的paramcheck设为false(若不行把所有的go去掉),

应该还有其他好办法,我没有深入去想,你去吧,呵呵
 
1、直接用ADOConnection.Execute 执行,不要用 ADOQuery

2、要清除最后的GO语句,GO是控制台语句,不是SQL语句,只能在查询分析器里运行

3、确定过程中引用到的对象(表、视图等)都正确存在。也即过程本身不存在任何问题。
 
我这样写可以通过:
var
i:integer;
s:WideString;
begin
//if ADOQuery1.Active then ADOQuery1.Close ;
//ADOQuery1.ExecSQL ;
s := 'if exists (SELECT id'
+' FROM sysobjects'
+' WHERE (id = OBJECT_ID(N''p1234'')) AND (OBJECTPROPERTY(id, N''IsProcedure'') = 1))'
+' drop PROCEDURE p1234';
ADOConnection1.Execute(s,i,[eoExecuteNoRecords]);

s :='CREATE PROCEDURE p1234;1 AS begin select 1 as d end';
ADOConnection1.Execute(s,i,[eoExecuteNoRecords]);
s := 'CREATE PROCEDURE p1234;2 AS begin select 1 as d end';
ADOConnection1.Execute(s,i,[eoExecuteNoRecords]);
end;
但是我这样写就不行了
var
i:integer;
s:WideString;
begin
//if ADOQuery1.Active then ADOQuery1.Close ;
//ADOQuery1.ExecSQL ;
s := 'if exists (SELECT id'
+' FROM sysobjects'
+' WHERE (id = OBJECT_ID(N''p1234'')) AND (OBJECTPROPERTY(id, N''IsProcedure'') = 1))'
+' drop PROCEDURE p1234';
s :=s + #13#10+ 'CREATE PROCEDURE p1234;1 AS begin select 1 as d end';
s := s + #13#10+ 'CREATE PROCEDURE p1234;2 AS begin select 1 as d end';
ADOConnection1.Execute(s,i,[eoExecuteNoRecords]);
end;
为什么不能一次执行多个呢?如果要执行多个,我要怎么处理?
 
我还是将分平分了吧,....
 
后退
顶部