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!

UPDATE error due to list box

Status
Not open for further replies.

Kactus

MIS
Jul 1, 2001
49
AU
Hello people,

Being reasonably new to ASP I’m struggling with what (I think) should be easy.

Is there a trick to updating a record in an Access DB when the values come from listboxes on a form?

I have a bunch of text fields on a form that update just fine but as soon as I add a list box (that gets it’s values dynamically from a lookup table) to the mix the record won’t update. A click of the submit button give you ‘can’t load page’ not even debugging information!

I’ve looked at the source for the code once it’s hit my browser and the <select> seems well formed. I’ve sent the SQL to the screen using response.write and it looks okay, too!

Thanks for any and all help/suggestions/drugs
Dave
 
yup code please (of the select box and of the asp page)...

Known is handfull, Unknown is worldfull
 
without the code post my first guess would be if you're populating a list/dropdownbox via data , you're overlooking some single or double quotes in the data and html formatting, or possibly assigning the visible/value of the option tag incorrectly.

hope the info helps, other than that i'm blind without code.
 
Thanks guys,
I'll post the code as soon as I deal with this morning's junkmail-mountain.

Dave
 
246 junk mail notes.

The code so far is listed below. I think I've made it worse by fiddling with it (I HATE that!)

Again, any help anyone can offer is greatly appreciated.

Dave.
---------

[tt]
<%@LANGUAGE=&quot;VBSCRIPT&quot; CODEPAGE=&quot;1252&quot;%>
<%
option explicit
Dim rsAnniversary
Dim rsCurrency
Dim rsAwards
Dim oconn
Dim ssql
Dim rsAwards_id
rsAwards_id= &quot;20&quot;
If (Request.QueryString(&quot;awardID&quot;) <> &quot;&quot;) Then
rsAwards_id = Request.QueryString(&quot;awardID&quot;)
End If
Set oconn=server.createobject(&quot;ADODB.Connection&quot;)
oconn.open(&quot;driver={microsoft access driver (*.mdb)};dbq=&quot;& server.mappath(&quot;\gcraawards\db\dave.mdb&quot;))

' Update Record: construct a sql update statement and execute it
If ((request.form(&quot;updateFlag&quot;)) <> &quot;&quot; And (request.form(&quot;recordID&quot;)) <> &quot;&quot;) Then
ssql = &quot;UPDATE awards SET &quot;
ssql = ssql & &quot;shortDesc = '&quot; & cstr(request.form(&quot;shortDesc&quot;)) & &quot;', &quot;
ssql = ssql & &quot;longDesc = '&quot; & cstr(request.form(&quot;longDesc&quot;)) & &quot;', &quot;
ssql = ssql & &quot;Anniversary = '&quot; & UCase(cstr(request.form(&quot;anniversary&quot;))) & &quot;', &quot;
ssql = ssql & &quot;rrp = &quot; & request.form(&quot;rrp&quot;) & &quot;, &quot;
ssql = ssql & &quot;currency = '&quot; & cstr(request.form(&quot;currency&quot;)) & &quot;', &quot;
ssql = ssql & &quot;picture = '&quot; & cstr(request.form(&quot;picture&quot;)) & &quot;'&quot;
ssql = ssql & &quot; WHERE awardID = &quot; & request.form(&quot;recordID&quot;)
' set rsAwards=oconn.execute(ssql)
' Response.Redirect(&quot;edit.asp&quot;)
Response.write (ssql)
End If

'populate rsAwards
ssql=&quot;SELECT awardID, Anniversary, Currency, current, longDesc, Picture, rrp, shortDesc FROM Awards WHERE awardID = &quot; + rsAwards_id
set rsAwards=oconn.execute(ssql)

%>
<html xmlns=&quot;<head>
<link href=&quot;Standard.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;>
<title>Edit Item</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; />
</head>
<body>
<form ACTION=&quot;testupdate2.asp&quot; METHOD=&quot;POST&quot; name=&quot;edititem&quot; id=&quot;edititem&quot;>
<table width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td width=&quot;23%&quot;>Short Description</td>
<td width=&quot;77%&quot;><input name=&quot;shortDesc&quot; type=&quot;text&quot; id=&quot;shortDesc&quot; value=&quot;<%=(rsAwards.Fields.Item(&quot;shortDesc&quot;).Value)%>&quot; size=&quot;45&quot; /></td>
</tr>
<tr>
<td>Long Description</td>
<td><textarea name=&quot;longdesc&quot; id=&quot;longdesc&quot; cols=&quot;40&quot; rows=&quot;5&quot;><%=(rsAwards.Fields.Item(&quot;longDesc&quot;).Value)%></textarea></td>
</tr>
<tr>
<td>Anniversary</td>

<td><select name=&quot;anniversary&quot; id=&quot;anniversary&quot;>
<% ssql=&quot;SELECT * FROM luAnniversary&quot;
set rsAnniversary=oconn.execute(ssql)%>
<%
While (NOT rsAnniversary.EOF)%>
<option value=&quot;<%=(UCase(rsAnniversary.Fields.Item(&quot;anniversary&quot;).Value))%>&quot; <%If (Not isNull((rsAwards.Fields.Item(&quot;Anniversary&quot;).Value))) Then If UCase((CStr(rsAnniversary.Fields.Item(&quot;anniversary&quot;).Value)) = UCase(CStr((rsAwards.Fields.Item(&quot;Anniversary&quot;).Value)))) Then Response.Write(&quot;SELECTED&quot;) : Response.Write(&quot;&quot;)%> ><%=(rsAnniversary.Fields.Item(&quot;desc&quot;).Value)%></option> <%rsAnniversary.MoveNext()
Wend %>
</select>
<%
rsAnniversary.Close()
Set rsAnniversary = Nothing
%>
</td>
</tr>
<tr>
<td>RRP</td>

<td><input name=&quot;rrp&quot; type=&quot;text&quot; id=&quot;rrp&quot; value=&quot;<%=(rsAwards.Fields.Item(&quot;rrp&quot;).Value)%>&quot; size=&quot;45&quot;></td>
</tr>
<tr>
<td>Currency</td>
<% ssql=&quot;SELECT * FROM luCurrencyType&quot;
set rsCurrency=oconn.execute(ssql)%>
<td><select name=&quot;currency&quot; id=&quot;currency&quot;><%
While (NOT rsCurrency.EOF)%>
<option value=&quot;<%=(rsCurrency.Fields.Item(&quot;Currency&quot;).Value)%>&quot; <%If (Not isNull((rsAwards.Fields.Item(&quot;Currency&quot;).Value))) Then If (CStr(rsCurrency.Fields.Item(&quot;Currency&quot;).Value) = CStr((rsAwards.Fields.Item(&quot;Currency&quot;).Value))) Then Response.Write(&quot;SELECTED&quot;) : Response.Write(&quot;&quot;)%> ><%=(rsCurrency.Fields.Item(&quot;Currency&quot;).Value)%></option>
<%rsCurrency.MoveNext()
Wend %>
</select><%
rsCurrency.Close()
Set rsCurrency = Nothing
%></td>
</tr>
<tr>
<td>Picture</td>

<td><input type=&quot;text&quot; name=&quot;picture&quot; id=&quot;picture&quot; value=&quot;<%=(rsAwards.Fields.Item(&quot;picture&quot;).Value)%>&quot; size=&quot;45&quot;></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot; /> <input type=&quot;reset&quot; name=&quot;Submit2&quot; value=&quot;Reset&quot; /></td>
</tr>
</table>
<input type=&quot;hidden&quot; name=&quot;updateFlag&quot; value=&quot;edititem&quot;>
<input type=&quot;hidden&quot; name=&quot;recordID&quot; value=&quot;<%= rsAwards.Fields.Item(&quot;awardID&quot;).Value %>&quot;>
</form>
</body>
</html>
<%
rsAwards.Close()
Set rsAwards = Nothing
%>
[/tt]
 
Can you also post:

1) The source HTML from this page as output by the browser

2) A response.write of the UPDATE query formed by the subsequent processing asp page

please...
 
looks like the page is working to me, you may want to put in a conditional statement in the loop for the list box population on if listboxRS(&quot;Currency&quot;) = CurrrentRS(&quot;Currency&quot;) then <option selected value=&quot;<%=listboxrs(&quot;Currency&quot;)%>&quot;> Etc...
 
The page is working for me too...

Known is handfull, Unknown is worldfull
 
Okay,

Thanks very much for having a look and trying, guys. At least I know it's not the code (whew!)

I'll keep digging and see what I can find.

Cheers,
Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top