472,364 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,364 software developers and data experts.

Add record does not add to DB

Hi Everyone

I am new to this forum and ASP programming in general. I am writing a warranty registration system and have written the data retrieval modules successfully. I am having problems with the ADD RECORD module.

I am using a ACCESS 2003 MDB file. I do not get any error at all... but the new record just is not created.

<%

Dim s_cno, s_email
Dim s_var
Dim s_dop
Dim s_invno
Dim s_model
Dim s_sno
Dim s_units
Dim mySQL, myData
Dim objRS, objRS2


s_email=Request.Form("f_email")
s_var=request.Form("f_var")
s_dop=request.Form("f_dop")
s_invno=request.Form("f_invno")
s_model=request.Form("f_model")
s_sno=request.Form("f_sno")
s_units=request.Form("f_units")

' Declare values

mySQL = "select * from cust where email='"& s_email &"'"

' OPEN DATABASE!!!!

Set dbCONN=Server.CreateObject("ADODB.Connection")
dbCONN.ConnectionTimeout=60
dbCONN.Open"DSN=wreg"

' Open the recordset

Set objRS=Server.CreateObject("ADODB.RecordSet")
call objRS.open( mySQL,dbConn, 0, 1 )

' Get Customer Number

s_cno = objRS.Fields("cno").value

' Now open the SERIAL table for write

myData = "Select * from serial"

Set objRS2=Server.CreateObject("ADODB.RecordSet")
' objRS2.open "SELECT * from Serial", dbCONN, adOpenStatic, adLockBatchOptimistic, adCmdText
objRS2.open "SELECT * from Serial", dbCONN, adOpenDynamic, adLockBatchOptimistic, adCmdText

objRS2.MoveLast
objRS2.AddNew

objRS2("cno") = s_cno
objRS2("var") = s_var
objRS2("dop") = s_dop
objRS2("invno") = s_invno
objRS2("model") = s_model
objRS2("sno") = s_sno
objRS2("units") = s_units

objRS2.Update

%>


I am not sure what is wrong.

Would appreciate your assistance.
Feb 22 '07 #1
4 1436
I have now put a small ON ERROR code in just before the UPDATE command.

On Error Resume Next
objRS2.Update

If ERR <> 0 then
Response.Write("ERROR: "& ERR)
End if

The error it prints is: ERROR: -2147467259

What is this ??
Feb 22 '07 #2
I have tried another method using INSERT.

But now the error trap tells me that I do not have permission to update the databse. I have already set the security in IIS to LOW for the DB directory.

The code is as follows:

<%

Dim s_cno, s_email
Dim s_var
Dim s_dop
Dim s_invno
Dim s_model
Dim s_sno
Dim s_units
Dim mySQL, myData
Dim objRS, objRS2


s_email=Request.Form("f_email")
s_var= request.Form("f_var")
s_dop= request.Form("f_dop")
s_invno= request.Form("f_invno")
s_model= request.Form("f_model")
s_sno= request.Form("f_sno")
s_units= request.Form("f_units")

' Declare values

mySQL = "select * from cust where email='"& s_email &"'"

' OPEN DATABASE!!!!

Set dbCONN=Server.CreateObject("ADODB.Connection")
dbCONN.ConnectionTimeout=60
dbCONN.Open"DSN=wreg"

' Open the recordset

Set objRS=Server.CreateObject("ADODB.RecordSet")
call objRS.open( mySQL,dbConn, 0, 1 )

' Get Customer Number

s_cno = objRS.Fields("cno").value

' Now open the SERIAL table for write

myData = "Select * from serial"
Set objRS2=Server.CreateObject("ADODB.RecordSet")
objRS2.open "SELECT * from Serial", dbCONN

MySQL = "INSERT INTO SERIAL (cno, var, dop, invno, model, sno, units) VALUES (s_cno, s_var, s_dop, s_invno, s_model, s_sno, s_units)"

on error resume next
dbCONN.Execute MySQL,recaffected
if err<>0 then
Response.Write("No update permissions!")
else
Response.Write("<h3>" & recaffected & " record added</h3>")
end if
objRS.close
set objRS=Nothing
objRS2.close
set objRS2=Nothing
dbCONN.Close
Set dbCONN=Nothing
%>

Appreciate some help please.
Feb 22 '07 #3
mwood
5
If this is on a windows server using iis then the IUSR_ServerName has to have permission to read and write to the database.
Feb 23 '07 #4
vijaydiwakar
579 512MB
I have tried another method using INSERT.

But now the error trap tells me that I do not have permission to update the databse. I have already set the security in IIS to LOW for the DB directory.

The code is as follows:

<%

Dim s_cno, s_email
Dim s_var
Dim s_dop
Dim s_invno
Dim s_model
Dim s_sno
Dim s_units
Dim mySQL, myData
Dim objRS, objRS2


s_email=Request.Form("f_email")
s_var= request.Form("f_var")
s_dop= request.Form("f_dop")
s_invno= request.Form("f_invno")
s_model= request.Form("f_model")
s_sno= request.Form("f_sno")
s_units= request.Form("f_units")

' Declare values

mySQL = "select * from cust where email='"& s_email &"'"

' OPEN DATABASE!!!!

Set dbCONN=Server.CreateObject("ADODB.Connection")
dbCONN.ConnectionTimeout=60
dbCONN.Open"DSN=wreg"

' Open the recordset

Set objRS=Server.CreateObject("ADODB.RecordSet")
call objRS.open( mySQL,dbConn, 0, 1 )

' Get Customer Number

s_cno = objRS.Fields("cno").value

' Now open the SERIAL table for write

myData = "Select * from serial"
Set objRS2=Server.CreateObject("ADODB.RecordSet")
objRS2.open "SELECT * from Serial", dbCONN

MySQL = "INSERT INTO SERIAL (cno, var, dop, invno, model, sno, units) VALUES (s_cno, s_var, s_dop, s_invno, s_model, s_sno, s_units)"

on error resume next
dbCONN.Execute MySQL,recaffected
if err<>0 then
Response.Write("No update permissions!")
else
Response.Write("<h3>" & recaffected & " record added</h3>")
end if
objRS.close
set objRS=Nothing
objRS2.close
set objRS2=Nothing
dbCONN.Close
Set dbCONN=Nothing
%>

Appreciate some help please.

I think in the qry
MySQL = "INSERT INTO SERIAL (cno, var, dop, invno, model, sno, units) VALUES (s_cno, s_var, s_dop, s_invno, s_model, s_sno, s_units)"

u've not concanected the values this qry should be like this try this
MySQL = "INSERT INTO SERIAL (cno, var, dop, invno, model, sno, units) VALUES (" & s_cno &"," & s_var & "," & s_dop &"," & s_invno & "," s_model &"," & s_sno &"," & s_units &")"
Feb 24 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Mary Litten | last post by:
Hi - (This is my very first post) I have gotten to this point of registering to post because I have been spinning my wheels so long, I believe I am all caught up in the weeds. (and mud) I have...
1
by: Steve | last post by:
I have a form with about 30 fields. Much of data entry for this form involves the same data for many of the fields. To save typing time, in the form's AfterUpdate event I run a procedure that sets...
15
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
3
prn
by: prn | last post by:
Hi folks, I've got something that's driving me crazy here. If you don't want to read a long explanation, this is not the post for you. My problematic Access app is a DB for keeping track of...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.