Solved

Jscript and ADO batch update

Posted on 2004-08-03
3
519 Views
Last Modified: 2008-03-17
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
Comment
Question by:biz1976
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
neeraj523 earned 300 total points
ID: 11701809
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
 

Author Comment

by:biz1976
ID: 11701926
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
 

Author Comment

by:biz1976
ID: 11702569
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question