我用以下语句建立一个简单数据库列表,若将其命名为"record",建立完成后,
将其所有内容都删除,第二次再用"record"建立一列表,此时奇怪的事发生了,
数据列表竟然没建立,而且以下语句的第一句话"if not mytable.Exists then"
的值是false,说明表已经存在,可我已将其所有信息都删除了,请问哪位高手有解决
之方法,谢谢!!
..................
if not mytable.Exists then
if label1.Caption='New Record Name :' then
begin
ctable:=Tquery.Create(nil);
ctable.DatabaseName:='agilent';
ctable.SessionName:='default';
s1:=format('create table %s (记录号 integer not null,当前值 float not null)',[edit1.text]);
with ctable do
begin
active:=false;
sql.Clear;
sql.Add(s1);
Prepare;
ExecSQL;
free;
end;
end
.................
将其所有内容都删除,第二次再用"record"建立一列表,此时奇怪的事发生了,
数据列表竟然没建立,而且以下语句的第一句话"if not mytable.Exists then"
的值是false,说明表已经存在,可我已将其所有信息都删除了,请问哪位高手有解决
之方法,谢谢!!
..................
if not mytable.Exists then
if label1.Caption='New Record Name :' then
begin
ctable:=Tquery.Create(nil);
ctable.DatabaseName:='agilent';
ctable.SessionName:='default';
s1:=format('create table %s (记录号 integer not null,当前值 float not null)',[edit1.text]);
with ctable do
begin
active:=false;
sql.Clear;
sql.Add(s1);
Prepare;
ExecSQL;
free;
end;
end
.................
用过之后就删掉
例如:
Create Procedure AAAA
As
select * into #t from table
select * from #t
Drop table #t
如果感觉用存储过程不方便SQL语句就麻烦点
先判断
select.Text='select * from sysobjects where Name=表名'
if query.fieldbyName('Name').value<>null then
Sql.text:='drop talbe 表名'
然后再写你的SQL语句
我用了 'drop talbe'语句 可是他说我'access violation at address XXXXXXXX in module'
两位朋友的方法我都试了
可都是这样
该怎么办??