No you don't :-) You may connect without a DNS. From the DBD::ODBC's docs:
Connect without DSN
The ability to connect without a full DSN is
introduced in version 0.21.
Example (using MS Access):
my $DSN = 'driver=Microsoft Access Driver (*.mdb);dbq=\\\\cheese\\g$\\
+perltest.mdb';
my $dbh = DBI->connect("dbi:ODBC:$DSN", '','')
or die "$DBI::errstr\n";
HTH, Jenda
Always code as if the guy who ends up maintaining your code
will be a violent psychopath who knows where you live.
-- Rick Osborne
Edit by castaway: Closed small tag in signature | [reply] [d/l] |
Here is a sneaky way that takes advantage of the fact that there is one access DB per file: no more, no less.
- Get a list of your databases
- Copy the first DB to temp.mdb
- Create an ODBC to temp.mdb
- Process temp.mdb as needed
- Close the DB connect ($dbh->disconnect())
- Delete the DB (unlink(temp.mdb))
- Copy the next DB to temp.mdb
- Loop....
Hope it helps! -Tats
| [reply] [d/l] [select] |
First, another option would be to use OLE. But probably the most easy solution would be to write a macro in the Access db that you what everything to be in. Under Macros look up the function transferDatabase. All you have to do is create a Dir lookup, then process each db with the "transferDatabase" function.
Not very perlish, but then using the right tool for the job is very perlish. | [reply] |
Good idea, but if the databases to be transferred are large, you may quickly hit the limits of Access' database engine. This will depend on the version you are running, so it pays to check this beforehand. CountZero "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law
| [reply] |
True, you always have to make sure your tools can handle the load. In this case this person wants to move 4,500 db into one. This makes me think that the size of each of the 4,500 db is actually small. If not then he will probably hit the 2G limit of the db. The quickest test would be to see how big the folder is that is holding the dbs. Each db will have some additional overhead that will be gained during the move, but if the folder is below 2G he should be good to go.
As a quick check I generated a empty db. It took up 100k so in its current state he is losing at least.450,000K of space.
Enough of THIS, let's get back to Perl!!!
| [reply] |
Jenda's previous post has the right idea, but I'd like to correct the terminology.
That is DSN, not "DNS", and I would name the variable "$connectionstring", instead of $DSN. | [reply] |