Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading MS Access tables

Status
Not open for further replies.

PinkeyNBrain

IS-IT--Management
Dec 12, 2006
279
0
0
US
The goal is to read MS Access tables. I have some code that has worked, but I can't get it to work consistently. Looking to find out what I'm missing:

Surfing, I found this code:
Code:
    package require dde
    set request "$mdbfile;TABLE $table"
    set it [dde request MSAccess $request All]
    foreach line [split $it \n] {
	puts [string map {\t ;} $line]
    }
I did little more than cut-n-paste it into an active coding session and it worked. Reboot PC, wouldn't work 2nd time
error said:
dde command failed"
I mess around, ensure proper file path "if file exists xxx", use console to cd into same directory, cut-n-paste table name to verify spelling, all the usual alpha-coding level testing stuff. After 10 minutes of messing around, it'll work. Reboot - back to same error. Found DDE2.0 package (was using 1.2.2), loaded it, new error but still not working.
error said:
Invalid connection Id for "request" function!
Tried to search DDE2.0 source code for error string to help determine root cause - nothing.

Any ideas?

HDWR: 64-bit HP laptop
SFWR: Win7, tclversion=8.4, MS2010-64bit version
I've heard feedback about MS2010-64bit being quirky, will be looking to find a 32-bit version to test the code against later today. The fact that I did get this to work several times keeps making me think I'm missing something.
 
jicote - Thanks for the input. I'll keep the ODBC idea in mind for future mods.
I've been fussing with this routine a lot since the post. Amongst the pain of trial-n-error on this, I’ve found a number of things that were not obvious to me at first:
1) This works cleaner if I actively have the *.mdb file open somewhere. It can probably be logically opened w/i the program and accessed, but the generic double-click the source file letting the OS open it, then accessing it through the programs DDE works.
2) I can get it to work on a 64-bit system more consistently using the 1.2.2 version of the code. So far it has been working 100% on 32-bit Win7 systems regardless of the DDE version being used. Since this will be used 99.99% of the time on a 32-bit PC, I’ve forgone further development on a 64-bit PC.

I am curious about the ODBC method largely for one of speed. In general I am not a fan of Access and am gearing the whole project toward moving the data to either simple flat files or perhaps MySQL. Historically I’ve found ODBC to be too fragile across hostile networks (I’m working in a manufacturing environment using PCs on wireless – when some of the electric cranes move through the area, the EMF fields around them destroy data transmissions.) But the previous contracted programming house left me with an MS-Access based database that works in theory but is having trouble on the plant floor.

Again, thanks for the lead. I’ll be looking into it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top