S
sns
Unregistered / Unconfirmed
GUEST, unregistred user!
unit C13001;interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, jpeg, ExtCtrls, StdCtrls, Buttons, ComCtrls, DB, ADODB,Mypublic,getconn; procedure CreateQuery; procedure CreateProc ; var QryC13001:TAdoQuery; implementation//////////////////////////////////////////////////////////////////////////////// Procedure CreateQuery; //动态创建查询组件 begin QryC13001:=TAdoQuery.Create(nil); QryC13001.Connection :=AdoConn; end;//////////////////////////////////////////////////////////////////////////////// procedure CreateProc ; //动态创建 存储过程 var DelProc,CreateProc:string; begin //判断数据库里是否有存贮过程,如果有就删除 DelProc:='IF EXISTS (SELECT name FROM sysobjects WHERE name = ''ProcC13001'' AND type =''P'')'+ 'DROP PROCEDURE ProcC13001' ; //动态创建ProcC13001存贮过程 CreateProc:='Create Procedure ProcC13001' + '(' + '@SubCode varchar(9),' + '@AccNo varchar(60)' + ')' + ' AS ' //AS前、后各加一个空格,否则提示错误 + 'insert into TemC13001 values ' + '(' + '@Subcode,' + '@AccNo' + ')' ;//============================================================================== {try //删除存贮过程 with QryC13001 do begin close; sql.Clear; sql.Add(DelProc) ; execsql; end; finally QryC13001.Free ; end; //============================================================================== try //创建删除存贮过程 with QryC13001 do begin close; sql.Clear; //执行到这里,发生错误,请帮助解决. sql.Add(CreateProc) ; execsql; end; finally QryC13001.Free ; end; end;////////////////////////////////////////////////////////////////////////////////end.