这个网站里面有一个把delphi界面修改的。
我不是很清楚你说的bde是什么意思。
http://aizb.6to23.com/

解决方案 »

  1.   

    c++builder:在运行时创建bde别名
        通过bde别名来连接数据库,确实很方便,然而,那些没有确定的数据库,我们却无法给它创建别名。
    而大多数时候,当我们把程序交给别人真正投入使用时,别名的路径也是不确定的。这就要求我们在程序
    运行时动态连接到数据库。
      现在,假设在程序运行目录下有个通讯录friends.db,我们要通过tquery、tdatasource等控件来访问:
    本人学习编程不久,如有错误或失漏,请不吝赐教在窗体上添加相关控件
    在头文件中声明会话句柄
    hdbises tmpsession;要在程序启动时装入数据库,可以如下:
    void __fastcall tmainfrm::formcreate(tobject *sender)
    {
            if (query1->state==dsinactive)
                    {
                    
                    dbiinit(null);//bde初始化
                    dbistartsession(null,tmpsession,"");//打开一个临时的bde session
                    //设别名路径为程序所在目录,要注意前头要加上"path:"字串
            ansistring strpath="path:"+extractfiledir(application->exename);
                    dbiaddalias(null,"tmpmyfriends",
                            "paradox",strpath.c_str(),false);//增加别名完成
                    query1->databasename="tmpmyfriends";//接下来就可如常使用了。
                    query1->active=true;                }
           
           query1->sql->clear ();
           query1->sql->add("select * from friends.db");
           query1->open();
    }  当程序关闭时,要记得释放bde占用的资源
    void __fastcall tmainfrm::formclose(tobject *sender, tcloseaction &action)
    {
            if (query1->active )
                    query1->active=false;
            dbiclosesession(tmpsession);//关闭当前会话
            dbiexit();//放掉bde资源}            可以说明一下的是dbistartsession和dbiaddalias函数。
     dbistartsession函数语法如下:
    dbiresult dbifn dbistartsession ([pszname], phses, [pnetdir]);
     其中,pszname参数是pchar类型指针,用来为最近打开的session命名,可以是null而让bde任意指定
    ;phses参数则用来指定你要找开的session的句柄。pnetdir为指向network路径的指针,具体我也没有用过。
    函数调用成功,则返回dbierr_none。
            dbiaddalias函数语法如下:
    dbiresult dbiaddalias( [hcfg], pszaliasname, pszdrivertype, pszparams, bpersistent );
     其中,hcfg指定要使用的配置文件,设null则把当前session加入配置文件;pszdrivertype指明数据
    库驱动类型,null表示为standard型。bpersitent为bool值,指定是否一直保存别名到配置文件中,如果为
    false则要加入的别名只有当前session中使用。函数如调用成功,返回dbierr_none。
      

  2.   

    Search and Create a new Alias with BDE calls.  
    Product:Delphi 3.x (or higher) 
    Uploader: Enrique Ortu 
      
    Question/Problem/Abstract:Search and Create a new Alias with BDE calls. 
    Answer:
    To create a temporary alias has been topic of other article similar of Dmitri Papichev, but the difference of the previous, that here I make direct calls to the BDE and I seek an equal alias before creating one new, therefore maybe interest to you. 1. Declare BDE, Dbtables  in USES section. 
    2. This set of sentences can be put on the part of initialization of the code of the form or maybe of a DataModule. 
    Var 
    AliasFound: Boolean; 
    TmpCursor: hDBICur; 
    Rslt: DBIResult; 
    Database: DBDesc; Begin 
    Check(DbiInit(nil)); 
    try 
    Check(DbiOpenDatabaseList(TmpCursor)); 
    AliasFound := False; 
      repeat 
        {Get a DBDesc record for the next alias} 
        rslt:= DbiGetNextRecord(TmpCursor, dbiNOLOCK, @Database, nil); 
        if (rslt <> DBIERR_EOF) then 
          if StrPas(Database.szName) = 'MyAlias' then 
            begin 
              {The alias MyAlias already exists} 
              AliasFound := True; 
              Break 
            end; 
      until rslt <> DBIERR_NONE; 
      Check(DbiCloseCursor(TmpCursor)); 
      if not AliasFound then 
        {If the alias was not found, add it to IDAPI.CFG} 
        Check(DbiAddAlias(nil,PChar('MyAlias'),nil, 
           PChar('PATH:'+ExtractFilePath(Application.ExeName)),True)) 
    finally 
      DbiExit; 
    end; 
    end;