Erro in recordset.AddNew()

THIS IS MY CODE AND I HAVE THE
ERROR MESSAGE AT THE END. IT SEEMS THE
rs.AddNew IS NOT RECOGNIZED.

I ALSO TRIED
rs.AddRecord() BUT GOT THE SAME ERROR.

thanks

Code
------
<% @LANGUAGE=JScript %>
<!-- METADATA TYPE="typelib" FILE="c:\Program Files\Common Files\System\ado\msado15.dll" -->

<%
var oConn;
var rs;
var name
oConn = Server.CreateObject("ADODB.Connection");
rs = Server.CreateObject("ADODB.Recordset");
try{    
  oConn.Open ("myDB");
   }
  catch (e)
{
// check for errors
Response.Write ("Error in Connecting to the database - data source")
Response.end
}
rs.CursorLocation = adUseClient;

try{    
   rs.Open ("Client", oConn, adOpenForwardOnly, adLockReadOnly, adCmdTable);
  }
  catch (e)
{
// check for errors
Response.Write ("Error in Opening the table in the database")
//Response.end
}

rs.AddNew();  //THIS IS LINE 32 WHERE THE ERROR IS REPORTED

 rs("fname") = "John";
rs.update();

%>

Error Message
-----------------------
Microsoft JScript runtime error '800a01b6'
Object doesn't support this property or method
/myfile/a.asp, line 32
yassin092898Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SiteSeeCommented:
You need to have the Virtual include to adojavas referenced at the very top of your script...
<%@ LANGUAGE = "JavaScript" %>
<!-- #Include file="adojavas.inc"  -->
0
SiteSeeCommented:
or...
 <%@ LANGUAGE = "JScript" %>
.... in your case
0
yassin092898Author Commented:
<%@ LANGUAGE = "JScript" %>
<!--#include file="adojavas.inc"-->

I have both lines at the top but it still complaining about
 rs.addNew(); call
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

SiteSeeCommented:
I actually know very little about JScript...(despite it's similarity to VBScript)..
here's the same kind of script in VBScript...and it works..

<%@ LANGUAGE = "VBScript" %>
<!-- #Include file="adovbs.inc"  -->

<%
set cn = Server.CreateObject("ADODB.Connection")
set rs = Server.CreateObject("ADODB.Recordset")

strConnect = "dsn=YOURDSN"

cn.Open strConnect

Set rs.ActiveConnection = cn
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
rs.Source = "TABLENAME"
rs.Open

rs.AddNew
      rs.Fields("AssociateName") = Request.Form("AssociateName")
      rs.Fields("AssociateContact") = Request.Form("AssociateContact")
      rs.Fields("AssociateUrl") = Request.Form("AssociateUrl")
      rs.Fields("AssociateMailingAddress") = Request.Form("AssociateMailingAddress")
      rs.Fields("AssociateCity") = Request.Form("AssociateCity")
      rs.Fields("AssociateState") = Request.Form("AssociateState")
      rs.Fields("AssociateCountry") = Request.Form("AssociateCountry")
      rs.Fields("AssociateZip") = Request.Form("AssociateZip")
      rs.Fields("AssociateEmail") = Request.Form("AssociateEmail")
      rs.Fields("AssociatePhone") = Request.Form("AssociatePhone")
      rs.Fields("AssociatePassword") = Request.Form("AssociatePassword")
rs.Update

Set rs = cn.Execute("YOUR_DB_QUERY_TO_RETURN_NEW_ID#")

%>

  <%
rs.close

cn.close

  %>

---------------------------
Make sense...??...just change your FormFieldValues

Steve
0
SiteSeeCommented:
Also, you can do Response.writes anywhere in the <body> that you want to display values from the form submission...
like this:

<%response.write Request.Form ("AssociateName")%>

-------------------------


and then do this at the very bottom of the page...:
 <%
rs.close

cn.close

  %>

</body>
</html>
--------------------


Steve
0
yassin092898Author Commented:
Steve thanks for the comment, I know VBScrit and I am trying to do te same with JScript.
0
SiteSeeCommented:
This doesn't seem complete:

rs.addNew();

....don't you need to have the object you want to add within the parentheses()??

....for instance, this is a jscript select query I have in one of my pages......
<%@ LANGUAGE=JScript %>
<!--#include file="adojavas.inc"-->
<%
// the line below is the connection string
//dbConnStr="DBQ="+Server.MapPath("/YOURFOLDER/YOURDATABASE.mdb")+";driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;";
dbConnStr="DBQ=YOURPATH\\YOURFOLDER\\YOURDATABASE.mdb;driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;";

// do some basic input error checking first. If the user tries to access this form w/o using the search form,
// send them to the error page
theTitle= new String(Request.QueryString("Title"));
theCategoryName= new String(Request.QueryString("CategoryName"));
theAuthorLastName= new String(Request.QueryString("AuthorLastName"));
thePage=Request.QueryString("p");
// if (!Inputs()) {
//      Response.Redirect("error.asp");
//      Response.End();
// }

// open the db, get the banner record, get the current results - make sure everything is OK before
// displaying the page, otherwise redir to the error page
conn=Server.CreateObject("ADODB.Connection");
res=Server.CreateObject("ADODB.Recordset");
conn.Open(dbConnStr);
res.Open("SELECT * FROM books WHERE (Title LIKE '"+theTitle+"' OR CategoryName LIKE '"+theCategoryName+"' OR AuthorLastName LIKE '"+theAuthorLastName+"') ORDER BY Title",conn, adOpenStatic, adLockReadOnly);
res.PageSize=5;
%>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">

<html>

-------------------------
Note that the sql query  and other objects are all INSIDE the parentheses...

maybe this is the problem??

Steve
0
robbertCommented:
Hi yassin!

There are several types of recordsets. You are currently using "adOpenForwardOnly", which means that the RS is read only, and you can move forward only. This is a fast method for listing results.

Instead, use "adOpenKeyset".

Regards, Robert
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.