Wrox Programmer Forums
|
BOOK: Beginning JavaScript
This is the forum to discuss the Wrox book Beginning JavaScript by Paul Wilton; ISBN: 9780764544057
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning JavaScript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 19th, 2006, 06:45 PM
Registered User
 
Join Date: Jun 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to marajade208
Default INSERT INTO STATEMENT NOT WORKING

Hello,

I am trying to insert a row into and access database embedded within a website.

I can successfully Delete and Update records, but I get an error when I try to insert. Here is the code (successful update and delete and unsuccessful insert into).

Insert Into (Unsuccessful)

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 mySQL = "INSERT INTO users (user_Id, tm_Number, lname, fname, password, Access) Values ('test',12345,'testfirst','testlast','vader2',1) ";
adoConnection.Open(strConnection);
var adoRecordset = Server.CreateObject("ADODB.Recordset");
adoRecordset=adoConnection.Execute(mySQL);


Delete: (Successful)

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 mySQL = "UPDATE users SET Access = 1 where user_Id = 'marajade208'";
adoConnection.Open(strConnection);
var adoRecordset = Server.CreateObject("ADODB.Recordset");
adoRecordset=adoConnection.Execute(mySQL);


Update: (Successful)

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 mySQL = "DELETE from users where user_Id = 'test'";
adoConnection.Open(strConnection);
var adoRecordset = Server.CreateObject("ADODB.Recordset");
adoRecordset=adoConnection.Execute(mySQL);


Thanks for any help!!!
 
Old June 19th, 2006, 08:50 PM
Registered User
 
Join Date: Jun 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to marajade208
Default

Also,

Can someone explain to me why this code works:
__________________________________________________ _
<%@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 mySQL = "INSERT INTO access_Levels ([value], [level]) VALUES (4,'qe')";
adoConnection.Open(strConnection);
var adoRecordset = Server.CreateObject("ADODB.Recordset");

adoRecordset=adoConnection.Execute(mySQL);

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

but this code will insert the data, but still give me an error?

__________________________________________________ ________________
<%@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;
%>
__________________________________________________ _________________


Thanks
 
Old June 20th, 2006, 11:43 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Did you try to response.write those fields to make sure the correct values are being provided? Also, for the client code, did you ensure that tm_number is a number data type, and that the other data types are correct? No length violations, and such as well?

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
iff statement not working barmanvarn BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 3 January 23rd, 2009 04:25 PM
Insert into statement not working. alisonchase Access ASP 8 January 16th, 2005 10:52 AM
Simple but not working IF THEN statement nlicata Classic ASP Databases 6 June 6th, 2003 10:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.