我要使用ADOQuery的UpdateBatch模式时,遇到这样的问题
procedure TForm1.Button4Click(Sender: TObject);
begin
DM1.ADOConnection1.ConnectionString:='Provider=SQLOLEDB.1;Password=nohacker;Persist Security Info=True;User ID=sa;Initial Catalog=master;Data Source=192.168.235.113';
with DM1.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from sysdatabases where name=''aaa'';');
Open;
if RecordCount>0 then
begin
Showmessage('数据库已经存在');
end;
end;
end;procedure TForm1.Button5Click(Sender: TObject);
begin
DM1.ADOConnection1.ConnectionString:='';
DM1.ADOConnection1.ConnectionString:='Provider=SQLOLEDB.1;Password=nohacker;Persist Security Info=True;User ID=sa;Initial Catalog=master;Data Source=192.168.235.113';
with DM1.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('create database aaa;');
ExecSQL;
showmessage('OK');
end;
end;procedure TForm1.Button6Click(Sender: TObject);
begin
DM1.ADOConnection1.ConnectionString:='';
DM1.ADOConnection1.ConnectionString:='Provider=SQLOLEDB.1;Password=nohacker;Persist Security Info=True;User ID=sa;Initial Catalog=master;Data Source=192.168.235.113';
with DM1.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('drop database aaa;');
ExecSQL;
showmessage('OK');
end;
end;运行单独的没有问题,但是只要运行其中的一个事件后,再点其他的事件,就会出现提示说“对象打开时,操作不被允许”。
请问如何解决,急啊。
procedure TForm1.Button4Click(Sender: TObject);
begin
DM1.ADOConnection1.ConnectionString:='Provider=SQLOLEDB.1;Password=nohacker;Persist Security Info=True;User ID=sa;Initial Catalog=master;Data Source=192.168.235.113';
with DM1.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from sysdatabases where name=''aaa'';');
Open;
if RecordCount>0 then
begin
Showmessage('数据库已经存在');
end;
end;
end;procedure TForm1.Button5Click(Sender: TObject);
begin
DM1.ADOConnection1.ConnectionString:='';
DM1.ADOConnection1.ConnectionString:='Provider=SQLOLEDB.1;Password=nohacker;Persist Security Info=True;User ID=sa;Initial Catalog=master;Data Source=192.168.235.113';
with DM1.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('create database aaa;');
ExecSQL;
showmessage('OK');
end;
end;procedure TForm1.Button6Click(Sender: TObject);
begin
DM1.ADOConnection1.ConnectionString:='';
DM1.ADOConnection1.ConnectionString:='Provider=SQLOLEDB.1;Password=nohacker;Persist Security Info=True;User ID=sa;Initial Catalog=master;Data Source=192.168.235.113';
with DM1.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('drop database aaa;');
ExecSQL;
showmessage('OK');
end;
end;运行单独的没有问题,但是只要运行其中的一个事件后,再点其他的事件,就会出现提示说“对象打开时,操作不被允许”。
请问如何解决,急啊。
CacheSize:=500;
CursorLocation:=clUseClient;
CursorType:=ctStatic;
LockType:=ltBatchOptimistic;
而是用ADOQuery的SQL语句来实现的UPDATE或者是INSERT
我想知道是不是用SQL语句的话,就直接写入数据库,而没能用到缓冲啊?
如何实现用SQL语句也用到ADO组件的缓冲功能??
高手们,帮忙啊,分不够的话,另外开贴发分
如果用sql语句,
try
DM1.ADOConnection1.BeginTrans
//sql
//
DM1.ADOConnection1.CommitTrans
except
DM1.ADOConnection1.RollbackTrans
except