Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Entry Error...ASP/JS 1

Status
Not open for further replies.

kyjoey

Technical User
Jun 6, 2005
23
US
I am new to JS, so any help would be greatly appreciated.

The following code successfully inserts the data, but gives me an error.


Code:
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%> <% var strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=\\\\T03web01\\AreaWebs\\" +
 "Quality\\QA\\Systems\\TPD\\database\\tpd.mdb"; //Connection String var adoConnection = Server.CreateObject("ADODB.Connection");
var nu_m = parseInt(4);
var lev = String("qe");
var mySQL = "INSERT INTO access_Levels ([value], [level]) VALUES ("+nu_m+",'"+lev+"')"; adoConnection.Open(strConnection);
var adoRecordset = Server.CreateObject("ADODB.Recordset");
adoRecordset=adoConnection.Execute(mySQL);

adoRecordset.Close();
adoRecordset = null;
adoConnection.Close();
adoConnection = null;
%>

Could anyone help me to what I am not doing or something I am missing?

Thanks again,
Joey

-Joey
 
The problem here is that you are defining a recordset but not ever using it. You are running one sql statement - an insert. Inserts do not return recordsets. The only thing they generally return is something like "1 row(s) affected".

What you're technically doing here is assigning a new recordset object to adoRecordset, then you are immediately reassinging that variable to the Execute method called on the connection object - which at this point I'm not really sure what adoRecordset technically holds, but it definitely ceases to be a recordset object because you have reassigned it to something else.

After the Execute statement is called, you are attempting to run the Close method on adoRecordset, but it is likely giving you the error because it is not a recordset object anymore.

So, from what I can tell, you can get rid of the recordset object altogether because it's not needed. Try making these changes:

Code:
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%> <% var strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=\\\\T03web01\\AreaWebs\\" +
 "Quality\\QA\\Systems\\TPD\\database\\tpd.mdb"; //Connection String var adoConnection = Server.CreateObject("ADODB.Connection");
var nu_m = parseInt(4);
var lev = String("qe");
var mySQL = "INSERT INTO access_Levels ([value], [level]) VALUES ("+nu_m+",'"+lev+"')"; adoConnection.Open(strConnection);

adoConnection.Execute(mySQL);

adoConnection.Close();
adoConnection = null;
%>

-kaht

[small]How spicy would you like your chang sauce? Oh man... I have no idea what's goin' on right now...[/small]
[banghead]
 
Bam!! That got it, and it makes sense. Thank you SO MUCH!

-Joey
 
[thumbsup2] glad it helped

-kaht

[small]How spicy would you like your chang sauce? Oh man... I have no idea what's goin' on right now...[/small]
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top