Announcement

Collapse
No announcement yet.

ASP script inserting into Access Database

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • ASP script inserting into Access Database

    Can someone help me find out what is wrong with this script. It just simple jsp inserting into an access database.

    Code:
    <html>
    <head>
    <title>Entitled Document</title>
    <script language="JavaScript" >
    
    function getSubmit()
    {
    var LastName;
    var Firstn = names.value ;
    
    var cn = new ActiveXObject("ADODB.Connection");
    //here you must use forward slash to point strait
    var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:\db1.mdb";
    var rs = new ActiveXObject("ADODB.Recordset");
    //var SQL = "INSERT INTO Customers(FirstName, Surname)"
    //+ " VALUES ( '"+ names.value +"', '" + surname.value +"')";
    var SQL = "select Surname, DOB from Customers where FirstName = '" + Firstn + "'";
    
    cn.Open(strConn);
    rs.Open(SQL, cn);
    surname.value = rs(0);
    DOB.value = rs(1);
    //alert(rs(0));
    rs.Close();
    cn.Close();
    
    
    }
    
    </script>
    </head>
    <body>
    
    <input type="text" name="names" />
    <input type="text" name="surname" />
    <input type="text" name="DOB" />
    <input type="button" value="Submit" onclick="getSubmit()">
    
    </body>
    </html>
    When I try to run it, it I get an error:
    Line: 37
    Char: 1
    Error: Object Expected
    Code: 0

    Maybe I am going about the wrong way as well. Any help would be appreciated.

    [Moderator comment: Line 37 highlighted in red to make it easier to find.]
    Last edited by biggles77; 16th January 2008, 05:19. Reason: wrong code used. Had asp needs to be jsp
Working...
X