in reply to How to insert more than one column into Access database table?

In your SQL statement, you have to specify which colums to insert the values in:
INSERT INTO T_table (col1,col2,col3) VALUES($ID,$Folder, $Webpage)
Your script 2 is trying to pass off SQL as genuine Perl but is not fooling the compiler at all, hence the error for script 2.

CU
Robartes-

  • Comment on Re: How to insert more than one column into Access database table?
  • Download Code

Replies are listed 'Best First'.
Thanks, but it does not work.
by Yelenna2003 (Initiate) on Oct 08, 2002 at 21:59 UTC
    Hi, Thanks. But I have only three columns in T_table: ID,Folder, Webpage. When I change the SQL statement like this: INSERT INTO T_table (ID, Folder, Webpage) VALUES ($ID, $Folder, $Webpage). The compiler tells me there is a syntax error: bareword found near ")VALUES". I do not know why. Helen
      You need to quote non-numeric values when using SQL that way. Better would be to use placeholders:
      my $sth = $dbh->prepare("insert into t_table (id, folder, webpage) values (?,?,? +)"); $sth->execute($id, $folder, $webpage);
      Update:Oops. /me notices you are using Win32::ODBC. Ignore the above code then, unless you switch to DBI. You still need to put quotes around any non-numeric values though...
      You're trying to modify your second code version. The addition of quotes around the non-numeric data recommended by the other monks should be done in the first code sample you posted, ie $sqlinsert ="INSERT INTO T_table (T_tableID, Folder, Webpage)  VALUES($ID,'$Folder', '$Webpage')";

      rdfield