|
-
Sep 15th, 2000, 11:17 AM
#1
Thread Starter
Frenzied Member
Is it possible to create a linked table in Access via
VB code rather than doing it from within Access?
For example, I want to create a linked table in an
Access db named db1.mdb. The text file will be named data.txt
and reside in c:\.
Please assume that Access will not be installed on the end user machine so I do not want to use Access objects..
Any help or guidance would be appreciated..
Dan
-
Sep 15th, 2000, 12:55 PM
#2
Try this:
Code:
Dim db As Database
Dim td As TableDef
On Error Goto ErrHnd
Set db = Workspaces(0).OpenDatabase("c:\db1.mdb")
set td = db.CreateTableDef("TextFileTable")
td.Connect = "c:\YourDirectory\"
td.SourceTable = "data.txt"
db.TableDefs.Append td
Exit Sub
ErrHnd:
MsgBox Err.Description
When you distribute your application, you will need to distribute DAO library as well.
Regards,
-
Sep 15th, 2000, 02:13 PM
#3
Thread Starter
Frenzied Member
Thanks, works great! But, is there a way to do it in ADO? I just want to minimize the amount of code to distribute and I use ADO for everything else.. I tried in ADO but there doesn't seem to be a TableDef feature...
Any ideas would be great!
Dan
-
Sep 15th, 2000, 03:16 PM
#4
-
Sep 15th, 2000, 04:03 PM
#5
Thread Starter
Frenzied Member
Wow, why does it look so much more complicated than using DAO? Also, I'm not sure what ADOX is but I wanted to use ADO. Is it one and the same? If not, is there an ADO example that you can provide me?
Thanks,
Dan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|