已解决
 
如何程序建立别名
提问者:Nicholas   回答:1  浏览次数:641     悬赏分:0

 
|  评论(0) |

请问如何程序建立别名?

如果有了满意的回答请及时采纳,不要辜负了回答者!
回答
 
共 1 条
 
最佳答案
回答者:Tom(Tom)  级别:沙场军衔-中校 (2006-12-07 18:11:48)
下面这篇文章是来自Inprise(Borland),它全面地介绍了有关别名的问题。 
    This Technical Information document will help step thru concepts regarding the creation and use of ALIASES within your Delphi Applications. 
     
    Typically, you use the BDE Configuration Utility BDECFG.EXE to create and configure aliases outside of Delphi. However, with the use of the TDatabase component, you have the ability to create and use this ALIAS within your application-- not pre-defined in the IDAPI.CFG. 
     
    The ability to create Aliases that are only available within your application is important. Aliases specify the location of database tables and connection parameters for database servers. Ultimately, you can gain the advantages of using ALIASES within 
    your applications-- without having to worry about the existance of a configuration entry in the IDAPI.CFG when you deploy your application. 
     
    Summary of Examples: 
    ------- -- --------- 
    Example #1: 
     Example #1 creates and configures an Alias to use STANDARD (.DB, .DBF) databases. The Alias is then used by a TTable component. 
    Example #2: 
     Example #2 creates and configures an Alias to use an INTERBASE database (.gdb). The Alias is then used by a TQuery component to join two tables of the database. 
    Example #3: 
     Example #3 creates and configures an Alias to use STANDARD (.DB, .DBF) databases. This example demonstrates how user input can be used to configure the Alias during run-time. 
     
    Example #1: Use of a .DB or .DBF database (STANDARD) 
     
    1. Create a New Project. 
    2. Place the following components on the form: 
     - TDatabase, TTable, TDataSource, TDBGrid, and TButton 
    3. Double-click on the TDatabase component or choose Database Editor from the TDatabase SpeedMenu to launch the Database Property editor. 
    4. Set the Database Name to 'MyNewAlias'. This name will serve as your ALIAS name used in the DatabaseName Property for dataset components such as TTable, TQuery, TStoredProc. 
    5. Select STANDARD as the Driver Name. 
    6. Click on the Defaults Button. This will automatically add a PATH= in the Parameter Overrides section. 
    7. Set the PATH= to C:\DELPHI\DEMOS\DATA (PATH=C:\DELPHI\DEMOS\DATA) 
    8. Click the OK button to close the Database Dialog. 
    9. Set the TTable DatabaseName Property to 'MyNewAlias'. 
    10. Set the TDataSource's DataSet Property to 'Table1'. 
    11. Set the DBGrid's DataSource Property to 'DataSource1'. 
    12. Place the following code inside of the TButton's OnClick event. 
     
     procedure TForm1.Button1Click(Sender: TObject); 
     begin 
     Table1.Tablename:= 'CUSTOMER'; 
     Table1.Active:= True; 
     end; 
     
    13. Run the application. 
     
    *** If you want an alternative way to steps 3 - 11, place the following code inside of the TButton's OnClick event. 
     
     procedure TForm1.Button1Click(Sender: TObject); 
     begin 
     Database1.DatabaseName:= 'MyNewAlias'; 
     Database1.DriverName:= 'STANDARD'; 
     Database1.Params.Clear; 
     Database1.Params.Add('PATH=C:\DELPHI\DEMOS\DATA'); 
     Table1.DatabaseName:= 'MyNewAlias'; 
     Table1.TableName:= 'CUSTOMER'; 
     Table1.Active:= True; 
     DataSource1.DataSet:= Table1; 
     DBGrid1.DataSource:= DataSource1; 
     end; 
     
 
 
提问者对答案的评价:
 
 
    谢谢哈!!
 |  评论(0) |
提问者请及时处理问题
 
  公告区
  本周推荐专家
专家 专业分类
  Copyright © 2003-2005 Forlink Technologies All Rights Reserved 
版权所有 时力科技 联系:客户服务中心 京ICP证030637号