我想在dll中调用数据库,把控件动态的加入程序,如何写代码呢?

解决方案 »

  1.   

    各位大虾给分析以下错误的原因。
    提示“miss connection or connectstring”var
      adoconnection1:TAdoconnection;
      adotable1:Tadotable;
    begin
      adoconnection1:=TAdoconnection.Create(nil);
      adotable1:=TAdotable.Create(nil);
      
      try
         with adoconnection1 do
           begin
            ConnectionString:='Provider=SQLOLEDB.1;Persist Security   
            info=False;User ID=sa;Initial Catalog=wlks;Data  Source=ASKGOD';
            connected:=true;
            loginprompt:=false;
            open('sa','');
           end;
            
           if adotable1.active then adotable1.close;
           adotable1.name:='alluser';
           adotable1.open;/****就是一执行到这句就出错,去掉就可以了*****/
           //adotable1.active:=true;
           showmessage('正确联结数据库');
       except
           SHOWMESSAGE('失敗!');
       end;
      

  2.   

    你的ADOTABLE控件的CONNECTION属性,应设置为ADOCONNECTION1
      

  3.   

    adotable1.connction:=adoconnection1;
    adotable1.tablename:='alluser';
    adotable1.open;
    ================================================================