• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 522
  • Last Modified:

Jscript and ADO batch update

OK....

Now i have this code - but it doesn't seem to be updating the records i want! And i don't get any error messages either! :o((

Incidently, i'm new to Jscript - i've only ever used vbscript before in conjunction with ASP - can someone please take a look and tell me what the problem may be????

<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/cnx.asp" -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
var Msg
var cnnSearch = Server.CreateObject("ADODB.Connection");
cnnSearch.Open(cnx_STRING);
var sqlstr = "SELECT DISTINCTROW * FROM [Personnel Details_real] WHERE [Employee Reference] = " & Request.QueryString("id") & ";"
var rst = Server.CreateObject("ADODB.Recordset");
rst.Open("[Personnel Details_real]", cnnSearch, 2, 3);

   if (Request.Form["txtcpdref"] != "") {
        rst["CPDRef"] == Request.Form["txtcpdref"];
            Msg == "Yeah it saved!"
    }
    else {
        rst["CPDRef"] == null;
    }

    rst.Update();
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<%=Msg%>
</body>
</html>
0
biz1976
Asked:
biz1976
  • 2
1 Solution
 
neeraj523Commented:
Hello

replace this

if (Request.Form["txtcpdref"] != "") {
        rst["CPDRef"] == Request.Form["txtcpdref"];
          Msg == "Yeah it saved!"
    }
    else {
        rst["CPDRef"] == null;
    }

TO

if (Request.Form["txtcpdref"] != "") {
        rst["CPDRef"] = Request.Form["txtcpdref"]
          Msg = "Yeah it saved!"
    }
    else {
        rst["CPDRef"] = null;
    }

neeraj523
0
 
biz1976Author Commented:
Hey Neeraj,

Thanks for the above - however - i now get an error saying:

Microsoft JScript runtime error '800a01b6'

Object doesn't support this property or method

/techsupport/save_emailaddress.asp, line 13

if (Request.Form["txtcpdref"] != "") {
        rst["CPDRef"] = Request.Form["txtcpdref"] <------- line 13
          Msg = "Yeah it saved!"
    }
    else {
        rst["CPDRef"] = null;
    }
0
 
biz1976Author Commented:
It's ok - Thanks Neeraj i've sorted it now.  Thanks for your help.

The problems i had were these:

In the rst.Open statement - i forgot to replace the table name with the sqlstr variable.  And also, when doing request.forms, and referencing specific fields within the recordset object - u musn't use square brackets and instead use curly brackets!

Thanks for the help
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now