ClioSport.net

Register a free account today to become a member!
Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

  • When you purchase through links on our site, we may earn an affiliate commission. Read more here.

VB/ASP question, probably easy for a geek



Basically I got a page which lists all the records in a database:

screen1.jpg


When the user clicks the button on left under staff ID they are then shown the following:

screen2.jpg


The above was coded using ASP and SQL, the above shows the update one and when clicked any changes are saved, I have exactly the same code for the delete, its brought up in similar window but there is a "delete record" button at bottom instead, basically I want delete record and update record both on same page, I have the code for both how do I put them together on one page?

Think its to do with VB or ASP, where u have "if" or "else" statements!

Code for update is:

<form method="post" action="demo_update.asp">
<table>
<%for each x in rs.Fields%>
<tr>
<td><%=x.name%></td>
<td><input name="<%=x.name%>" value="<%=x.value%>"></td>
<%next%>
</tr>
</table>
<br /><br />
<input type="submit" value="Update record">
</form>
<%
else
sql="UPDATE staff SET "
sql=sql & "sname='" & Request.Form("sname") & "',"
sql=sql & "fname='" & Request.Form("fname") & "',"
sql=sql & "dob='" & Request.Form("dob") & "',"
sql=sql & "dept='" & Request.Form("dept") & "'"
sql=sql & " WHERE staffid=" & cid & ""
on error resume next
conn.Execute sql
if err<>0 then
response.write("No update permissions!")
else
response.write("Record " & cid & " was updated!")
end if
end if
conn.close
%>


Code for delete is :

<form method="post" action="demo_delete.asp">
<table>
<%for each x in rs.Fields%>
<tr>
<td><%=x.name%></td>
<td><input name="<%=x.name%>" value="<%=x.value%>"></td>
<%next%>
</tr>
</table>
<br /><br />
<input type="submit" value="Delete record">
</form>
<%
else
sql="DELETE FROM staff"
sql=sql & " WHERE staffid=" & cid & ""
'on error resume next
conn.Execute sql
'if err<>0 then
'response.write("No update permissions!")
response.write("Record " & cid & " was deleted!")
end if
conn.close
%>


Basically how do I merge them together so they are both on same page?

Cheers!!!!
 
Yea, I was going to have the delete part as a funtion, and update part as a function, but how do I call a function on the click of a submit button?
 

KDF

  Audi TT Stronic
Just use a different name/value on the submit button, do an if/switch to find out if the value is delete or update and call the appropriate function based on that.
 


Top