|
-
Sep 20th, 1999, 06:09 PM
#1
Thread Starter
Hyperactive Member
I am trying a small example of attaching a textfile to the biblio.mdb, I have set up a empty table called mytable with the fields
name (text)
age (text)
color (text)
I have also set up a .dat file like this
"name","age","color"
"mark","12","red"
"karen","39","blue"
"paul","33","green"
"cee-jay","87","yellow"
"brandon","35","pink"
I want to attach this text file into the database which I presume has a tabledef already (as I have made it in visdata)
I have tried this code to do the task but it won't work, any help would be appreciated. Could you also explain any code submitted in layman's terms as I am relatively new to db programming!.
Option Explicit
Dim mydb As Database
Dim myrs As Recordset
Private Sub Command1_Click()
Dim tdf As TableDef
On Error GoTo errorhandler
Set tdf = mydb.CreateTableDef("mytable")
tdf.Connect = "c:\begDB\biblio.mdb"
tdf.SourceTableName = "c:\Mark\attachfile.dat"
mydb.TableDefs.Delete ("mytable")
mydb.TableDefs.Append tdf
Exit Sub
errorhandler:
MsgBox " crashed and burned baby!"
MsgBox = MsgBox & Err.Number
Exit Sub
End Sub
Private Sub Form_Load()
Set mydb = OpenDatabase("c:\begDB\biblio.mdb")
End Sub
Thanks again ! > locutus
-
Sep 20th, 1999, 09:34 PM
#2
Try this:
Code:
Dim db As Database
Dim td As TableDef
On Error Goto ErrHnd
Set db = Workspaces(0).OpenDatabase("c:\begDB\biblio.mdb")
set td = db.CreateTableDef("MyTable")
td.Connect = "c:\Mark\"
td.SourceTable = "attachfile.dat"
db.TableDefs.Append td
Exit Sub
ErrHnd:
MsgBox Err.Description
Regards,
------------------
Serge
Software Developer
[email protected]
[email protected]
-
Sep 21st, 1999, 12:19 PM
#3
Thread Starter
Hyperactive Member
Thanks for replying to my query Serge !
When I try the code above I get the err
3170 Couldn't find installable ISAM
I know this is Index Sequential Access Method
but don't understand whats going on :-(
please could you spare a minute to help
Thanks > locutus
-
Sep 21st, 1999, 02:37 PM
#4
Do you have MS Access installed? If you do, then you should have that ISAM driver installed. To check if the driver is installed do the following:
1. Open Control Panel.
2. Select ODBC32 (or ODBC Data Sources) and double click on it.
3. Click on Add button
If you see something like this:
Microsoft Text Driver (*.txt;*.csv) then you have it installed. If you don't then you can get this driver from Microsoft's Web site. Unfortunately, I can't give you the exact link, but I think if you search their site, you can find it.
Regards,
------------------
Serge
Software Developer
[email protected]
[email protected]
[This message has been edited by Serge (edited 09-22-1999).]
-
Sep 21st, 1999, 02:59 PM
#5
Thread Starter
Hyperactive Member
Thanks again !
I did like you said and do have both the access driver and text driver installed.
This was meant to be a small test program to try out attaching text files to a pre defined, empty database. Do you have any further advice ?
Any help is much appreciated :-)
> locutus
-
Sep 21st, 1999, 03:47 PM
#6
Then the code above should work. I've checked the MSDN library and it doesn't even matter what version of DAO you use, the line:
td.Connect = "c:\Mark\"
should not give you a problem.
The only thing that I can think of is to try to reinstall Access.
Hope this will help.
Regards,
------------------
Serge
Software Developer
[email protected]
[email protected]
-
Sep 22nd, 1999, 07:19 PM
#7
Thread Starter
Hyperactive Member
In case you read this Serge I found what was missing.It should read
tdf.connect ="text;database =c:\Mark;"
when this bit was put in ie "text;database="
it worked fine !.
Ahhh you live and learn ( said in Homer type voice)
anyhow thanks for the pointers ->
locutus
-
Sep 24th, 1999, 01:47 AM
#8
Member
Minor thing Serge, this linking does not use the ODBC drivers, it uses only the Jet ISAM support drivers, which are MStextXX.dll for text/html, MSxbseXX.dll for dBase&foxpro, etc.
(When you deply, make sure the ISAM dlls that you need to sue are packaged with your setup)
------------------
http://www.smithvoice.com/vbfun.htm
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
|