我在数据库连接设置模块中引用了sqldmo_tlb单元~~~主要是用来获取局域网内所有PC的SQL数据库
可是不知为什么  application. 不能用了,程序运行时老是报错,没有定义类或对象~~
有哪位大哥知道怎么回事么~??谢谢~!!

解决方案 »

  1.   

    可以啊~~就在application.exename 这地方出错,说没定义类或对象,只要有applicaion就有错~~郁闷,不懂什么原因~!
    [Error] E_database.pas(118): Object or class type required
      

  2.   

    补充~一下~~如果把sqldmo_tlb单元去掉, 则可以运行~~没有错误~!
      

  3.   

    E_database.pas这个单元没有引用forms这个单元,还有你把那段贴出来看看
      

  4.   

    我有引用FORMS啊~~看看我的原码~: 这是其中的一处
    procedure TE_databasef.ComboBox2DropDown(Sender: TObject);
      var
          icount,Server_B:integer;
      begin
          combobox2.Items.Clear;
          Screen.Cursor:=CrHourGlass;
          Server_B:=combobox1.Items.IndexOf(combobox1.Text);
          with   PdmoObject[Server_B].SQL_DMO   do
          begin
              if   not   PdmoObject[Server_B].lConnected   then
              try
                  Connect(Name,Trim(combobox3.Text),Trim(edit1.Text));
              except
                  Screen.Cursor:=CrDefault;
                  Application.MessageBox('请检查用户名或密码是否正确','连接失败',MB_OK);//报错[Error] E_database.pas(202): Undeclared identifier: 'MessageBox'
                  Exit;
              end;
              if   not   VerifyConnection(SQLDMOConn_ReconnectIfDead)   then
                begin
                  ShowMessage('在试图连接到SQL   SERVER   2000  时出现错误'+#10#13 +'确信是否加在了动态连接库SQLDMO.DLL');
                  exit;
                end
              else
                  PdmoObject[Server_B].lConnected:=True;
                  Databases.Refresh(true);
              for   icount:=1   to   Databases.Count   do
               combobox2.Items.Add(Databases.Item(icount,null).name);
          end;
        Screen.Cursor:=CrDefault;
     end ;
      

  5.   

    [Error] E_database.pas(118): Object or class type required
    //这是错误是需要对象或类类型
    ///
    把E_database.pas的118行附近代码贴出来
      

  6.   

    这个是更改数据库连接的一个连接字符串的程序段:
     var addsini:tinifile;
            s:string;
    begin
      try
       begin
        if checkbox1.Checked then
          s:='Provider=SQLOLEDB.1;'+
             'Integrated Security=SSPI;Persist Security Info=False;'+
             'Initial Catalog='+combobox2.Text+';Data Source='+combobox1.Text+''
        else
          s:='Provider=SQLOLEDB.1;'+
              'Password='+edit1.Text+';'+
              'Persist Security Info=False;'+
              'User ID='+combobox3.Text+';'+
              'Initial Catalog='+combobox2.Text+';'+
              'Data Source='+combobox1.Text+';'+
              'Use Procedure for Prepare=1;'+
              'Auto Translate=True;'+
              'Packet Size=4096;'+
              'Workstation ID=hx05;'+
              'Use Encryption for Data=False;'+
              'Tag with column collation when possible=False';
       end;
           datamodule1.ADOConnection1.Connected:=false;
           datamodule1.ADOConnection1.ConnectionString:=s;
           datamodule1.ADOConnection1.Connected:=true;
     if datamodule1.ADOConnection1.Connected then
      begin
         if (combobox1.Text='') or (combobox2.Text='') or (combobox3.Text='') then
            i:=messagebox(handle,'数据连接必须值不能为空','警告',mb_iconwarning+mb_ok);
            i:=messagebox(handle,'确认要更改连接吗?各个数据库中的表并不相同,更改连接后有可能导致数据库连接失败!','警告',mb_yesno+mb_iconwarning);
         if i=idno then
            abort
         else
          begin
             addsini:=Tinifile.Create(extractfilepath(application.exename)+'login.ini');//错误[Error] E_database.pas(119): Object or class type required
             addsini.WriteString('database','server',combobox1.Text);
             addsini.WriteString('database','database',combobox2.Text);
             addsini.WriteString('database','user',combobox3.Text);
             addsini.WriteString('database','password',edit1.Text);
             addsini.WriteBool('database','if_windows_login',checkbox1.checked);
             close;
          end;
      end
      else
       except
           application.MessageBox('数据库连接失败,请检查配置文件','连接错误',mb_iconstop+MB_OK);
    //错误 [Error] E_database.pas(130): Object or class type required
       end;end;
      

  7.   

    还有一句是:
    try
       Connect(Name,Trim(combobox3.Text),Trim(edit1.Text));
     except
       Screen.Cursor:=CrDefault;
       Application.MessageBox('请检查用户名或密码是否正确','连接失败',MB_OK);
    //[Error] E_database.pas(202): Undeclared identifier: 'MessageBox'
       Exit;
     end;
      

  8.   

    sorry,i hava not time, send this unit to e-mail...ok?
    e-mail: [email protected]