Problem inserting to an Access database

Discussion in 'Perl' started by Alan Chiew, Sep 23, 2003.

  1. Alan Chiew

    Alan Chiew Guest

    Hi All,

    The following piece of code is what I have tried to update a simple
    Access database (none of the commented out code worked either). The
    connection to the database seems to be fine because I am able to read
    data from it. However, when trying to add another row of data, nothing
    seems to happen.

    I have also checked the permissions in IIS and they seem to be set up
    fine.

    Any ideas would be much appreciated.

    Regards,
    Alan

    <%@LANGUAGE = PerlScript%>

    <%
    use Win32::OLE;
    use Win32::OLE::Const 'Microsoft ActiveX Data Objects';

    $Conn = Win32::OLE->new("ADODB.Connection");
    $RS = Win32::OLE->new("ADODB.Recordset");

    $DBFile = "E:\\vhosts\\internaltest\\public_html\\ITRtest.mdb";

    $DSN = "PROVIDER=MSDASQL;DRIVER={Microsoft Access Driver (*.mdb)};
    DBQ=$DBFile;UID=;PWD=;";

    $Conn->Open($DSN);

    $RS->Open("test", $Conn, adLockOptimistic, adOpenDynamic);

    $fields = ["barcode", "desc"];
    $values = ["C999", "this"];

    $RS->AddNew($fields, $values);

    #$Conn->Open("INSERT INTO test VALUES ('aaa', 'bbb')");
    #$RS->Open($SQL, $Conn, 1, 1);

    #$SQL = 'insert into test (barcode) VALUES "C999"';
    #$RS = $Conn->Execute($SQL);

    #$RS->AddNew;
    #$RS->Fields('barcode')->{value} = "ABC";
    #$RS->Update;


    $RS->Close;
    $Conn->Close;
    %>
     
    Alan Chiew, Sep 23, 2003
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrija
    Replies:
    1
    Views:
    880
    William Ryan
    Oct 5, 2003
  2. Replies:
    0
    Views:
    486
  3. altergothen
    Replies:
    2
    Views:
    432
    Hans Kesting
    Apr 19, 2004
  4. Shapper
    Replies:
    2
    Views:
    670
    Paul Clement
    Jul 7, 2005
  5. hfk0
    Replies:
    5
    Views:
    823
  6. MA P

    Inserting to Access Database

    MA P, Sep 4, 2006, in forum: ASP .Net
    Replies:
    8
    Views:
    2,580
  7. Tony Johansson
    Replies:
    7
    Views:
    756
    Gregory A. Beamer
    Dec 23, 2009
  8. Navnath Gadakh

    problem in inserting record in ms access.

    Navnath Gadakh, Oct 4, 2012, in forum: Java
    Replies:
    5
    Views:
    503
    Arne Vajhøj
    Oct 6, 2012
Loading...