加个try
try
if edit1.Text='' then
  adoconnection1.ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Catalog=master;Data Source=ZZQ\ZZQSQLSERVER'
else
  adoconnection1.ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;'+'password='+edit1.Text+';Catalog=master;Data Source=ZZQ\ZZQSQLSERVER' ;
 adoconnection1.open;except
  application.message('密码输入有问题','报错',mb_ok);
end;
 if adoconnection1.Connected=true then
    begin
    form1.show;
    form4.hide;
    end
  else
    begin
      messagebox(handle,'connecting over time','error',mb_ok)
    end;
  end;