如果是用ADOConnection
ADOConnection.Connectstring:='*********';
ADOConnection.open;
就打开了。

解决方案 »

  1.   

    table1.open 或
    table1.active:=ture
      

  2.   

    我用的是table,想通过它的属性来设怎么设?
      

  3.   

    各位大虾:我要的是动态打开某某数据库文件的代码。
    如:现在得到某数据库的名m_database;我们没办法付给table啊。
    table.databasename:=m_database;老出错。不行啊
      

  4.   

    如果是Paradox之类的,很简单的
    table.databasename := path;//path 就是.db文件的本地目录了,如 c:\temp
    table.tablename := 'mytable1';
    table.open
    就可以了啊
    access我没有试过,应该差不多吧,如果要动态生成alias,可以用Session这个全局变量,里面
    有诸如createalias这样的方法(对不起,我现在没有在运行,可以记忆不是太准确的)
      

  5.   

    flypuma(飞豹)
    你的方法是对的。谢谢你啦。我一定会给你加分。
    大家对其他的数据库操作多发言啊。
      

  6.   

    你为什么不用ADO呢?有好用的不用却用TABLE!
      

  7.   

    如果数据库放在你的程序当前目录下,包括子目录,你可以用getcurrentdir得到路径再加上数据库名就可以实现动态连接了
      

  8.   

    继续加分啦!
    菜鸟问题,竟然没人能回答?
    顺便问一下:怎么生成dbf表;
    如下程序为什么出错:
     with table1 do
            begin
                { The Table component must not be active }
            Active := False;
                { First, describe the type of table and give }
                { it a name }
            DatabaseName :='c:\';        TableType := ttDefault;        TableName :='tmp.dbf'            { Next, describe the fields in the table }
                with FieldDefs do
                 begin
                   Clear;            with AddFieldDef do
                        begin                    Name := 'fields1';
                        DataType := ttfoxpro;
                        Required := True;
                        end;
                      with AddFieldDef do
                      begin
                         Name :='fields2';
                         DataType := ftstring;
                         Size := 20;
                      end;               end ;            end;
             { Next, describe any indexes }
               with IndexDefs do
               begin
                Clear;
                { The 1st index has no name because it is
                { a Paradox primary key }                  with AddIndexDef do
                          begin                       Name := '';
                           Fields := 'fields1';
                           Options := [ixPrimary];
                          end;
                      //其它字段                     with AddIndexDef do
                          begin
                          Name := 'fields2';
                          Fields := 'fields2';
                          Options := [ixCaseInsensitive];
                          end;
                    end;          { Call the CreateTable method to create the table }
              CreateTable;
              Active := true;         end;
      

  9.   

    呵呵,其中不小心多了些end;望大家见量。
    TableType := ttDefault;
    我改了很多类型。但是都不行。
    大家快教教我啊。