我也想知道,因为现在我有个东西也想这样做,由于路径的问题,装到其它机器上就不行了,我也想知道如何在程序中建立链接表。 我在大富翁上找了点东西,不知对你有否帮助,如果你解决了问题,请告诉我一下: 资料一: procedure TForm1.NssADOConnection1AfterConnect(Sender: TObject); var cat:olevariant; tdb:olevariant; begin cat:=createoleobject('adox.catalog'); cat.activeconnection:=NssAdoConnection1.ConnectionObject; tdb:=createoleobject('adox.table'); tdb:=cat.tables('abcdefg'); //本库中的链接表表名 tdb.Properties('jet oledb:link datasource'):='e:\db1.mdb'; //就是运行到此出现的错误,不知为何? end; 资料二: 总的来说是用adox,但要注意先import ado ext for ddl and security 李维那本讲ado的书上有介绍,把下面的vb代码改成delphi就是了HOWTO: Link and Refresh Linked Jet Tables Using ADOX-------------------------------------------------------------------------------- The information in this article applies to:ActiveX Data Objects (ADO), versions 2.1 , 2.1 SP1 , 2.1 SP2 , 2.5 , 2.6 , 2.7 -------------------------------------------------------------------------------- SUMMARY You can update the connection information for a linked table by using the Data Access Objects (DAO) RefreshLink method. This article describes another way to do this with ActiveX Data Objects (ADO) version 2.1 and later by using the Tables collection exposed by the ADO Extensibility model (ADOX). MORE INFORMATION In Microsoft Visual Basic, create a new Standard EXE project. Form1 is added to the project by default. On the Project menu, click References . From the list of available components, select Microsoft ActiveX Data Objects 2.1 Library and Microsoft ADO Ext. 2.1 for DDL and Security. Place two CommandButton controls on Form1: cmdRefreshLink and cmdCreateLinkedTable. Paste the following code in the Declarations section of Form1: Option ExplicitDim cn As ADODB.ConnectionPrivate Sub Form_Load() Set cn = New ADODB.Connection cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Db1.mdb" End SubPrivate Sub cmdCreateLinkedTable_Click() Dim cat As ADOX.Catalog Dim tbl As ADOX.Table
Set cat = New ADOX.Catalog Set tbl = New ADOX.Table ' Open the catalog. cat.ActiveConnection = cn
' Create the new Table. tbl.Name = "Linked_Employees" Set tbl.ParentCatalog = cat ' Set the properties to create the link. tbl.Properties("Jet OLEDB:Link Datasource") = "D:\nwind.mdb" tbl.Properties("Jet OLEDB:Remote Table Name") = "Employees" tbl.Properties("Jet OLEDB:Create Link") = True ' Append the table to the Tables collection. cat.Tables.Append tbl Set cat = Nothing End SubPrivate Sub cmdRefreshLink_Click() Dim cat As ADOX.Catalog Dim tbl As ADOX.Table
Set cat = New ADOX.Catalog Set tbl = New ADOX.Table
' Open the catalog. cat.ActiveConnection = cn For Each tbl In cat.Tables If tbl.Type = "LINK" And tbl.Name = "Linked_Employees" Then tbl.Properties("Jet OLEDB:Link Datasource") = "D:\OtherSource.mdb" End If Next End Sub Modify the code in the Form_Load() event to point the connection string to a valid Database in the cn.Open method. Modify the code in the cmdCreateLinkedTable_Click() event to point the connection string to the Northwind sample database in the tbl.Properties("Jet OLEDB:Link Datasource") assignment. Modify the code in the cmdRefreshLink_Click() event to point the tbl.Properties("Jet OLEDB:Link Datasource") assignment to another valid location. Run the project. The cmdCreateLinkedTable() procedure creates a linked table, Linked_Employees, from the Northwind sample database Employees table. The cmdRefreshLink() procedure refreshes the linked tables with a new database location. REFERENCES Q240222 HOWTO: Use ADO to Refresh/Create Linked Table for Password Secured Jet 4.0 Database "Defining and Retrieving a Database's Schema" http://msdn.microsoft.com/library/techart/daotoadoupdate.htm
因为要在程序里更新的
只有链接表才可以
也不想再建一个FOX的TADOconnection
除非可以在两个之间作SQL
SourceDB=Datapath;SourceType=DBF;Exclusive=No;BackgroundFetch=Yes;'
Ado的连接字符串,绝对没有问题!
是在ACCESS的.mdb库中新建立链接表(已有FOXPRO表)
不是联接
和普通的ACCESS表一样
支持ADO的操作
ODBC database方式
不到万不得已不想用access的appliction
我在大富翁上找了点东西,不知对你有否帮助,如果你解决了问题,请告诉我一下:
资料一:
procedure TForm1.NssADOConnection1AfterConnect(Sender: TObject);
var
cat:olevariant;
tdb:olevariant;
begin
cat:=createoleobject('adox.catalog');
cat.activeconnection:=NssAdoConnection1.ConnectionObject;
tdb:=createoleobject('adox.table');
tdb:=cat.tables('abcdefg'); //本库中的链接表表名
tdb.Properties('jet oledb:link datasource'):='e:\db1.mdb'; //就是运行到此出现的错误,不知为何?
end;
资料二:
总的来说是用adox,但要注意先import ado ext for ddl and security
李维那本讲ado的书上有介绍,把下面的vb代码改成delphi就是了HOWTO: Link and Refresh Linked Jet Tables Using ADOX--------------------------------------------------------------------------------
The information in this article applies to:ActiveX Data Objects (ADO), versions 2.1 , 2.1 SP1 , 2.1 SP2 , 2.5 , 2.6 , 2.7 --------------------------------------------------------------------------------
SUMMARY
You can update the connection information for a linked table by using the
Data Access Objects (DAO) RefreshLink method. This article describes another
way to do this with ActiveX Data Objects (ADO) version 2.1 and later by using
the Tables collection exposed by the ADO Extensibility model (ADOX). MORE INFORMATION In Microsoft Visual Basic, create a new Standard EXE project. Form1 is added
to the project by default.
On the Project menu, click References . From the list of available components,
select Microsoft ActiveX Data Objects 2.1 Library and Microsoft ADO Ext. 2.1
for DDL and Security.
Place two CommandButton controls on Form1: cmdRefreshLink and cmdCreateLinkedTable.
Paste the following code in the Declarations section of Form1:
Option ExplicitDim cn As ADODB.ConnectionPrivate Sub Form_Load()
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Db1.mdb"
End SubPrivate Sub cmdCreateLinkedTable_Click()
Dim cat As ADOX.Catalog
Dim tbl As ADOX.Table
Set cat = New ADOX.Catalog
Set tbl = New ADOX.Table ' Open the catalog.
cat.ActiveConnection = cn
' Create the new Table.
tbl.Name = "Linked_Employees"
Set tbl.ParentCatalog = cat ' Set the properties to create the link.
tbl.Properties("Jet OLEDB:Link Datasource") = "D:\nwind.mdb"
tbl.Properties("Jet OLEDB:Remote Table Name") = "Employees"
tbl.Properties("Jet OLEDB:Create Link") = True ' Append the table to the Tables collection.
cat.Tables.Append tbl
Set cat = Nothing
End SubPrivate Sub cmdRefreshLink_Click()
Dim cat As ADOX.Catalog
Dim tbl As ADOX.Table
Set cat = New ADOX.Catalog
Set tbl = New ADOX.Table
' Open the catalog.
cat.ActiveConnection = cn
For Each tbl In cat.Tables
If tbl.Type = "LINK" And tbl.Name = "Linked_Employees" Then
tbl.Properties("Jet OLEDB:Link Datasource") = "D:\OtherSource.mdb"
End If
Next
End Sub
Modify the code in the Form_Load() event to point the connection string to a valid Database in the cn.Open method.
Modify the code in the cmdCreateLinkedTable_Click() event to point the connection string to the Northwind sample database in the tbl.Properties("Jet OLEDB:Link Datasource") assignment.
Modify the code in the cmdRefreshLink_Click() event to point the tbl.Properties("Jet OLEDB:Link Datasource") assignment to another valid location.
Run the project.
The cmdCreateLinkedTable() procedure creates a linked table, Linked_Employees, from the Northwind sample database Employees table. The cmdRefreshLink() procedure refreshes the linked tables with a new database location. REFERENCES Q240222 HOWTO: Use ADO to Refresh/Create Linked Table for Password Secured Jet 4.0 Database
"Defining and Retrieving a Database's Schema"
http://msdn.microsoft.com/library/techart/daotoadoupdate.htm
我试试
第二种可以
不过只能联接MDB
vfp的表还有问题