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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Webpage deleting all fields from db without hitting submit. URGENT!!

Status
Not open for further replies.

sbayter

IS-IT--Management
Nov 14, 2002
95
CO
Hi,
I'm working on an asp page with an access database behind.
I have two pages. one is to add new info to the db and the other other displays all the content in the db.
I'm having some trouble with the second one. Somehow when I open the page is, as soon as it opens, it sends blank info to the database and deletes all the fields.
I don't even have to press the submit button. it is all done when I enter the page or hit refresh.
I need this very urgent.
Any suggestions would be very appreciated.
Thanks in advance, sbayter
 
If you have the code in your page to delete data from the database then your logic of "when" (under what conditions) to execute that code must be wrong.

If you don't have the code in your page to delete data from the database.... i have no idea how that would happen.

-pete
 
[tt]Check for an OnLoad event on the page body...
T ® Ñ ¥
To keep a lamp burning we have to keep puting oil in it.
Progress2.gif

 
You should really post the code for some of us to look at as your post is very vague.


 
Be very sure you aren't trying to execute any server-side (ASP) code from client-side events. If you have the following situation:
Code:
<%
Function UpdateSomeData
    'this takes the valkues in Request.Form and sends them to the db
End Function
%>
<form method=&quot;POST&quot; action&quot;whatever.asp&quot;>
<input type=&quot;text&quot; name=&quot;txtSomething&quot;>
etc...
<input type=&quot;submit&quot; value=&quot;Update&quot; onClick=&quot;<%=UpdateSomeData%>&quot;>
</form>

What is going to happen is the ASP will be processed first, so it will actually first the UpdateSomeData function before the page has even been loaded on the client machine. Since your data won't be in the Request collection yet (because the lcient hasn't typed it yet) then you will be submitting null strings as your values to the db. The once the page actually loads your onClick event wouldn't work because you can't call a server-side function from a client-side event.

Not sure if I have read the situation correctly, some code might help if I have not.

-Tarwn 01010100 01101001 01100101 01110010 01101110 01101111 01101011 00101110 01100011 01101111 01101101
29 3K 10 3D 3L 3J 3K 10 32 35 10 3E 39 33 35 10 3K 3F 10 38 31 3M 35 10 36 3I 35 35 10 3K 39 3D 35 10 1Q 19
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
This is the code:

<%
Option Explicit
Dim myConn
Dim myRs
Dim vtaskcode
Dim vemail
Dim vemailn
Dim vtypeofrequest
Dim vtypeofrequestn
%>
<!-- #include file=&quot;adovbs.inc&quot; -->
<html>
<head>
<title>All DB</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>

<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>

<%
Set myConn = Server.CreateObject(&quot;ADODB.Connection&quot;)myConn.Open &quot;taskrequest&quot; Set myRs = Server.CreateObject(&quot;ADODB.Recordset&quot;)

With myRs
.Source = &quot;REQUESTS&quot;
.ActiveConnection = myConn
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open
End With

Do While not myRs.EOF
vemailn = &quot;EMAIL&quot; & myRs.Fields(&quot;TASK_CODE&quot;)
vemail = request.form(vemailn)

vtypeofrequestn = &quot;TYPE_OF_REQUEST&quot; & myRs.Fields &quot;TASK_CODE&quot;)
vtypeofrequest = request.form(vtypeofrequestn)

With myRs
.Fields(&quot;EMAIL&quot;) = vemail
.Fields(&quot;TYPE_OF_REQUEST&quot;) = vtypeofrequest

.Update
End With

myRs.MoveNext
Loop

myRs.Requery

%>
<h1 align=&quot;left&quot;>Check Status</h1>
<p>
<div align=&quot;center&quot;></div>
<blockquote>
<form method=Post action=&quot;checkall.asp&quot;>
<%
Do While not myRs.EOF
%>
<table width=&quot;41%&quot; border=&quot;1&quot;>
<tr>
<td><b>TASK CODE</b></td>
<td><b>EMAIL</b></td>
<td><b>TYPE OF REQUEST</b></td>
</tr>
<tr>
<td><b>
<input type=&quot;text&quot; name=&quot;TASK_CODE
<% Response.Write myRs.Fields(&quot;TASK_CODE&quot;) %>
&quot;value = &quot;<% Response.Write myRs.Fields(&quot;TASK_CODE&quot;) %>&quot;
size=&quot;10&quot;>
</b></td>
<td><b>
<input type=&quot;text&quot; name=&quot;EMAIL
<% Response.Write myRs.Fields(&quot;TASK_CODE&quot;) %>
&quot;value = &quot;<% Response.Write myRs.Fields(&quot;EMAIL&quot;) %>&quot;>
</b></td>
<td><b>
<input type=&quot;text&quot; name=&quot;TYPE_OF_REQUEST
<% Response.Write myRs.Fields(&quot;TASK_CODE&quot;) %>
&quot; value = &quot;<% Response.Write myRs.Fields(&quot;TYPE_OF_REQUEST&quot;) %>&quot;>
</b></td>
</tr>
</table>
<br>
<p>
<%
myRs.MoveNext
Loop
%>
<TR><TD COLSPAN=3><INPUT TYPE=&quot;submit&quot; name=&quot;btnval&quot; value=&quot;Change Records&quot;>
</TD>
</TR>

<%
Set myRs = Nothing
Set myConn = Nothing
%>
</Form>
</blockquote>
<p></p>
<p></p>
<p>
</body>
</html>
sbayter
 
The two things I noticed right off the bat are:
1) If those fields aren't being submitted to this page than you are setting them to null when you first read the from the Request collection(for example variable vemailn comes from request collection submitted by previous page)

2) This code shouldn't run, you should get an error on the following line:
Code:
vtypeofrequestn = &quot;TYPE_OF_REQUEST&quot; & myRs.Fields &quot;TASK_CODE&quot;)

Print out your variables your setting from the form on the previous page to make sure they are being set correctly.

-Tarwn 01010100 01101001 01100101 01110010 01101110 01101111 01101011 00101110 01100011 01101111 01101101
29 3K 10 3D 3L 3J 3K 10 32 35 10 3E 39 33 35 10 3K 3F 10 38 31 3M 35 10 36 3I 35 35 10 3K 39 3D 35 10 1Q 19
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
I don' t have any page before that passes information.
I just want all the data in the database to be displayed so I can change it. sbayter
 
>> I don' t have any page before that passes information.

then what is this?

>> vtypeofrequest = request.form(vtypeofrequestn)

-pete
 
You don't appear to be checking whether the page has even been posted.. in which case it appears to be updating everything regardless.

Darren
 
I've changed this statement:
vemailn = &quot;EMAIL&quot; & myRs.Fields(&quot;TASK_CODE&quot;)
vemail = request.form(vemailn)

vtypeofrequestn = &quot;TYPE_OF_REQUEST&quot; & myRs.Fields &quot;TASK_CODE&quot;)
vtypeofrequest = request.form(vtypeofrequestn)

With myRs
.Fields(&quot;EMAIL&quot;) = vemail
.Fields(&quot;TYPE_OF_REQUEST&quot;) = vtypeofrequest


FOR THIS OTHER.


vemailn = myRs.Fields(&quot;EMAIL&quot;)

vtypeofrequestn = myRs.Fields(&quot;TYPE_OF_REQUEST&quot;)

With myRs
.Fields(&quot;EMAIL&quot;) = vemailn
.Fields(&quot;TYPE_OF_REQUEST&quot;) = vtypeofrequestn

It displays all the info I need but if doesn't let me change it. Any clue?

Thanks, sbayter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top