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

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

Replies are listed 'Best First'.
Re: Thanks, but it does not work.
by runrig (Abbot) on Oct 08, 2002 at 22:12 UTC
    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...
Re: Thanks, but it does not work.
by rdfield (Priest) on Oct 09, 2002 at 09:09 UTC
    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