By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,777 Members | 1,755 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,777 IT Pros & Developers. It's quick & easy.

Win32::ODBC-problem escaping "c:\new.mdb"

P: 87
I tried the following that didnt work

So far, the only thing that worked is "c:\\new" but I had to rename the destination access database to get rid of the .mdb

Here is a sql command that works just fine when giving it to the access wizard to execute as a query. It copies 3 columns from one database to another.
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO AvailableCourses  ( [Course ID], Grouping, [Course Title]) 
  2. IN "c:\\new.mdb"  
  3. SELECT [Course ID],Grouping, [Course Title] 
  4. FROM [Available Courses];
I then changed the above to do the following in perl:
Expand|Select|Wrap|Line Numbers
  1. $dbqS = "trainingdb.mdb";
  2. $dbh = DBI->connect('dbi:ODBC:driver=microsoft access driver (*.mdb);dbq='.
  3.     $dbqS.'','','',{RaiseError => 1,PrintError=>1}); 
  5. @AvailCourses = (
  6. 'INSERT INTO AvailableCourses ( [Course ID], Grouping, [Course Title]) IN "c:\\new.mdb"  SELECT [Course ID], Grouping, [Course Title] FROM [Available Courses];'
  7. );
  9. sub DoRunQueries {
  10.     my(@queries) = @{(shift)};
  11.     my($query);
  12.     foreach $query(@queries) {
  13.     $sqlcmd = $query;
  14.            print "$sqlcmd\n";
  15.     my $sth = $dbh->prepare($sqlcmd);
  16.                 $sth->execute();
  17.     }
  18. }
  19. DoRunQueries(\@AvailCourses);
this is the output, note the "invalid bracketing.."
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO AvailableCourses ( [Course ID], Grouping, [Course Title]) IN "c:\new .mdb"  SELECT [Course ID], Grouping, [Course Title] FROM [Available Courses];
  2. DBD::ODBC::db prepare failed: [Microsoft][ODBC Microsoft Access Driver] Invalid bracketing of name '[c:\new.mdb]'. (SQL-42000)(DBD: st_prepare/SQLPrepare err=-1)
A google of "invalid bracketing of name" gets a huge number of hits on problems with access databases. Maybe this is not a perl problem but I need an expert to tell me. Currently, I am renameing my destination database so it has no extension which is really a kluge.
Feb 20 '09 #1
Share this Question
Share on Google+
3 Replies

Expert 2.5K+
P: 4,059
did you try putting [] brackets around c:\new.mdb instead of double-quotes?

Expand|Select|Wrap|Line Numbers
  1. @AvailCourses = (
  2. 'INSERT INTO AvailableCourses ( [Course ID], Grouping, [Course Title]) IN [c:\new.mdb]  SELECT [Course ID], Grouping, [Course Title] FROM [Available Courses];'
  3. )
Feb 20 '09 #2

P: 87
solved: I needed single quote and that was the only one I didnt try :(

'c:\\new\.mdb' works

however I got a worse problem escaping the ":" but I will post it on a new thread
Feb 24 '09 #3

Expert 100+
P: 971
See my post in the other thread.

Feb 24 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.