Solved

Jscript and ADO batch update

Posted on 2004-08-03
3
513 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
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
neeraj523 earned 300 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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 Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now