Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 147
  • Last Modified:

Open/Insert/Save ????

I have a web app that has several ASP pages.

On one page I do a:
 select * from xxx WHERE var=abc

It then displays an input screen that has values from the DB if the record existed or blank fields if it didnt.

Currently when the submit is clicked the asp calls another ASP that does:

UPDATE xxx SET (then var string)

My Question is I wan this to be able to handle when a record was found or if it's new.  WHat do I have to do to make this happen?
0
pinkstonm
Asked:
pinkstonm
1 Solution
 
gladxmlCommented:
pinkstonm,

What do you mean... Could you please explain more further...
0
 
sybeCommented:
use the id of the record as reference, and use id=0 for a record that has to be inserted.


form :
=================

<%
iID = Cng("0" & Request.Querystring("id"))
sSQL = "SELECT * FROM table WHERE id = " & iID
Set oRS = connection.Execute(sSQL)
If Not oRS.EOF Then
  ' retrieve existing values
  sFirstName = oRS("first_name")
End If


%>


<form action="processrequest.asp" method="post">
<input type="hidden" name="id" value="<%=iID%>">

<input type="text" name="first_name" value="<%=sFirstName%>">

your other formfields here

</form>




======================
action:
======================

<%
iID = Cng("0" & Request.Querystring("id"))
If iID = 0 Then
   ' do an insert
Else
   ' do an update
End If
%>


0
 
sybeCommented:
typo:

iID = Cng("0" & Request.Querystring("id"))

must be

iID = Clng("0" & Request.Querystring("id"))
0
 
pinkstonmAuthor Commented:
Is iID = Cng("0" & Request.Querystring("id")) a standard command?

will that work for my table named capw where the var to be checked is sitenum?
0
 
Computer101Commented:
Points refunded and placed in PAQ

Computer101
E-E Admin
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now