S
sns
Unregistered / Unconfirmed
GUEST, unregistred user!
把二个控件放在一个UNIT能正确执行,放在二个UNIT中出现错误.以下代码是放在一个单元里.unit test;interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, jpeg, ExtCtrls, StdCtrls, Buttons, ComCtrls, DB, ADODB;function GetAdoConn(AdoConnString:string):boolean;implementationFunction GetAdoConn(AdoConnString:string):boolean; //连接到数据库var adoconn:Tadoconnection; DeleteTable, CreateTable :string; Qrytable:TAdoQuery;//动态创建ADO连接begin try adoconn:=TAdoconnection.Create(nil); with AdoConn do begin close; LoginPrompt := False; CommandTimeOut:=10; ConnectionString := AdoConnString; open; end; //with except AdoConn.Free; end; //try///////////////////////////////////////////////////////////////////动态创建Query组件 Qrytable:=TAdoQuery.Create(nil) ; Qrytable.Connection :=AdoConn; DeleteTable:='if exists(select * from sysobjects where name=''Temtable'')'+ 'drop table Temtable'; CreateTable:='Create Table Temtable' + '( ' + 'SubCode varchar(9),' + 'Tddeino int,' + ')' ; try with Qrytable do begin close; sql.Clear; sql.Add(DeleteTable) ; sql.Add(CreateTable) ; execsql; Result:=true; end; finally Result:=false; Qrytable.Free ; end; end;end.