Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Problem with editing records--Please help!


Message #1 by "Troy Wise" <passlake@h...> on Mon, 24 Feb 2003 20:04:48
Thank you in advance for your help!

I have an application in which a person enters information in a contact 
form.  The database has fields for tracking resolution of the contact:

resolved (true or false)
resolvedby (person fixing the problem)
resolution (action taken)

When someone goes to resolve a problem, they can click on the database 
record they wish to review and modify.  A page that describes the contact 
and has a form for these three fields comes up.  I want to be able to 
modify the resolved field and add content for the resolvedby and 
resolution fields.

I pass the record ID from the form to a handler.asp page.  This 
handler.asp page contains the following content:

<%
Set conn = Server.CreateObject("adodb.connection")
conn.ConnectionTimeout=60
conn.Open "dsn=kmc-mrk"
cid = Request.ServerVariables("ID")
res = Request.Form("resolved")
resby = Request.Form("resolvedby")
resolu = Request.Form("resolution")

Set RS=Server.CreateObject("ADODB.Recordset")
RS.Open "SELECT * FROM contact WHERE id="& cid , conn

IF res = "True" Then
	RS("resolved") = "True"
	RS("resolvedby") = & resby
	RS("resolution") = & resolu
	RS.update
END IF

Conn.Close
Set conn = Nothing
Response.Redirect "admin-contact-all.asp"
%>

What am I doing wrong??? I keep getting 500 errors and no updates...

Again, thank you for your time!

passlake
Message #2 by "Darrell" <darrell@b...> on Mon, 24 Feb 2003 20:37:53 -0000
Hi Troy

Might be easier if you could send in the error message but I reckon you will
need to declare the cursor type you will need.  Have a look at Ken's
resource: http://www.adopenstatic.com/faq/800a0bb9.asp#RecordsetOpenSyntax

You might want to consider updating using SQL rather than a recordset as
follows:

StrSql = "UPDATE contact SET resolved = 'True', resolvedby = '"&resby&"',
resolu = '"&resolution&"' WHERE id = "&cid&";"

Cheers
Darrell

-----Original Message-----
From: Troy Wise [mailto:passlake@h...]
Sent: 24 February 2003 20:05
To: Access ASP
Subject: [access_asp] Problem with editing records--Please help!

Thank you in advance for your help!

I have an application in which a person enters information in a contact
form.  The database has fields for tracking resolution of the contact:

resolved (true or false)
resolvedby (person fixing the problem)
resolution (action taken)

When someone goes to resolve a problem, they can click on the database
record they wish to review and modify.  A page that describes the contact
and has a form for these three fields comes up.  I want to be able to
modify the resolved field and add content for the resolvedby and
resolution fields.

I pass the record ID from the form to a handler.asp page.  This
handler.asp page contains the following content:

<%
Set conn = Server.CreateObject("adodb.connection")
conn.ConnectionTimeout=60
conn.Open "dsn=kmc-mrk"
cid = Request.ServerVariables("ID")
res = Request.Form("resolved")
resby = Request.Form("resolvedby")
resolu = Request.Form("resolution")

Set RS=Server.CreateObject("ADODB.Recordset")
RS.Open "SELECT * FROM contact WHERE id="& cid , conn

IF res = "True" Then
        RS("resolved") = "True"
        RS("resolvedby") = & resby
        RS("resolution") = & resolu
        RS.update
END IF

Conn.Close
Set conn = Nothing
Response.Redirect "admin-contact-all.asp"
%>

What am I doing wrong??? I keep getting 500 errors and no updates...

Again, thank you for your time!

passlake

Message #3 by "Josh Katsaros" <katsarosj@y...> on Mon, 24 Feb 2003 20:55:00
What exactly are you trying to do?  As far as I know, there is no server 
variable called "ID".  What it looks like you should be doing is placing a 
hidden variable on your form, name it "ID" and set that equal to the 
primary key from your database (id???).

Then your code would look something like:

RS.Open "SELECT * FROM contact WHERE id = " & Request.Form("ID"), conn

This assumes that your id field is numeric.  If it is a string, surround 
it with # signs.

I also don't see an INSERT or UPDATE statement in your code...

If this isn't what your are trying to do, list the error message you are 
getting.  That might help better to resolve it.

JK

> Thank you in advance for your help!

> I have an application in which a person enters information in a contact 
f> orm.  The database has fields for tracking resolution of the contact:

> resolved (true or false)
r> esolvedby (person fixing the problem)
r> esolution (action taken)

> When someone goes to resolve a problem, they can click on the database 
r> ecord they wish to review and modify.  A page that describes the 
contact 
a> nd has a form for these three fields comes up.  I want to be able to 
m> odify the resolved field and add content for the resolvedby and 
r> esolution fields.

> I pass the record ID from the form to a handler.asp page.  This 
h> andler.asp page contains the following content:

> <%
S> et conn = Server.CreateObject("adodb.connection")
c> onn.ConnectionTimeout=60
c> onn.Open "dsn=kmc-mrk"
c> id = Request.ServerVariables("ID")
r> es = Request.Form("resolved")
r> esby = Request.Form("resolvedby")
r> esolu = Request.Form("resolution")

> Set RS=Server.CreateObject("ADODB.Recordset")
R> S.Open "SELECT * FROM contact WHERE id="& cid , conn

> IF res = "True" Then
	> RS("resolved") = "True"
	> RS("resolvedby") = & resby
	> RS("resolution") = & resolu
	> RS.update
E> ND IF

> Conn.Close
S> et conn = Nothing
R> esponse.Redirect "admin-contact-all.asp"
%> >

> What am I doing wrong??? I keep getting 500 errors and no updates...

> Again, thank you for your time!

> passlake
Message #4 by "Troy Wise" <passlake@h...> on Wed, 26 Feb 2003 18:56:32
I do not get a specific error message; I only receive a "HTML 500" error, 
which says that the page cannot be displayed.

Thoughts?  Thanks!!!

Troy
Message #5 by "Jae Hou" <jae@s...> on Wed, 26 Feb 2003 19:07:26
This may be a user rights issue.  You may not have rights to write to it.  
Where is the mdb file located? 


> I do not get a specific error message; I only receive a "HTML 500" 
error, 
w> hich says that the page cannot be displayed.

> Thoughts?  Thanks!!!

> Troy
Message #6 by "Ken Schaefer" <ken@a...> on Thu, 27 Feb 2003 11:32:47 +1100
If you are using IE, turn off Friendly Errors (Tools -> INternet Options ->
Advanced -> Show Friendlty HTTP Errors) and reload your page to see the
error message coming from the server.

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Troy Wise" <passlake@h...>
Subject: [access_asp] Re: Problem with editing records--Please help!


: I do not get a specific error message; I only receive a "HTML 500" error,
: which says that the page cannot be displayed.
:
: Thoughts?  Thanks!!!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


  Return to Index