?
Solved

Open/Insert/Save ????

Posted on 2003-03-07
6
Medium Priority
?
145 Views
Last Modified: 2010-04-06
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
Comment
Question by:pinkstonm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 15

Expert Comment

by:gladxml
ID: 8092905
pinkstonm,

What do you mean... Could you please explain more further...
0
 
LVL 28

Expert Comment

by:sybe
ID: 8093798
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
 
LVL 28

Expert Comment

by:sybe
ID: 8093800
typo:

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

must be

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

Author Comment

by:pinkstonm
ID: 8096141
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
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 9104908
Points refunded and placed in PAQ

Computer101
E-E Admin
0

Featured Post

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question