这一点跟ado或者bde没有关系。
你如果多建几个工程文件你就会发现,在dpr文件中,第一句始终应该是Application.Initialize;只有这一句执行完了之后,才可能执行创建窗体的其他语句。所以你的错误也就在这里。至于你想要实现的功能,也并非那么复杂
  Application.Initialize;
  Application.CreateForm(TDataModule2, DataModule2);
  Application.CreateForm(TForm1, Form1);
  Application.Run;你可以按照上面的顺序去创建窗体,如果在datamodule2中验证失败的话,就可以直接在其中使用application.halt终止程序的运行。
另外,你提到的ado问题,可能是你的connectionoptions选择了异步连接导致的。

解决方案 »

  1.   

    这是我以前使用的以bde连接sql server的dpr文件内容:  Application.Initialize;  Svrname := 'SHTJ1';
      If not InputQuery('信息系统 ---- 主机设置','请输入主机名',svrname) then
      begin
        Application.Terminate ;
        exit;
      end;  Application.CreateForm(Tfmain, fmain);//主窗体
      Application.CreateForm(TFprepare, Fprepare);//flash窗体
      Fprepare.Show;
      Fprepare.Repaint ;  asl := Tstringlist.Create ;
      asl.Clear ;
      asl.Add ('Driver Name= MSSQL');
      asl.Add ('Server Name= ' + svrname);
      asl.Add ('Database Name= ' + Dname);
      asl.Add ('User Name= ' + Username);
      asl.Add ('sqlqrymode=local');  if not Session.IsAlias ('STJ') then
      begin
       try
         Session.AddAlias ('STJ','MSSQL',ASL);
        finally
         asl.Free ;
        end;
      end
      else if Session.IsAlias ('STJ') then
      begin
       try
         Session.ModifyAlias ('STJ',ASL);
        finally
         asl.Free ;
        end;
      end;
      Application.CreateForm(TDm, Dm);//数据模块  with Dm.SumdataBase do
      begin
        IF Connected = true then
        Connected := false;    aliasname := 'STJ';
        params.Clear ;
        params.Add ('server name=' + svrname);
        params.Add ('database name=' + Dname);
        params.Add ('user name=' + lname);
        params.Add ('password=' + lword);
        loginprompt := false;
        keepconnection := true;    try
          Connected := true;
        except
          application.MessageBox (pchar('无法启动数据库,请检查数据服务器是否已经启动!'),Pchar('错误'),mb_ok);
          application.Terminate ;
          exit;
        end;
      end;  Fprepare.Repaint;
      Fprepare.Release;
      Application.Run