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.
4 1470
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 ??
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.
If this is on a windows server using iis then the IUSR_ServerName has to have permission to read and write to the database.
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 &")"
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |