If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Submit rejection if spot is taken

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-26-03, 16:13
derpdaderp derpdaderp is offline
Registered User
 
Join Date: Jun 2003
Posts: 6
Submit rejection if spot is taken

Basically I have an ASP page that marks a certain spot where an item is. When the user wants to enter a new item, I want it so that if he tries to take up that same spot (There are many spots) while another item still maintains that spot, there is server side scripted language stating that either the spot is taken try again, or that the spot was free and the data submitted into the database. I've tried various techniques out and none of have worked for me so far.


The data for the spot in the submit pages is labeled as "Spot". Any help is appreciated.
Reply With Quote
  #2 (permalink)  
Old 07-01-03, 04:34
JonathanB JonathanB is offline
Registered User
 
Join Date: Feb 2002
Location: North Wales, UK
Posts: 114
Can you be a bit more specific to what a "spot" is? Such as what data is actually submitted? How it corresponds to the records in the database?

A simply way of storing in the script the status of say 20 "spots" is to use an array.
__________________
J^ - web | email
newsASP Developer
Reply With Quote
  #3 (permalink)  
Old 07-01-03, 07:19
derpdaderp derpdaderp is offline
Registered User
 
Join Date: Jun 2003
Posts: 6
I have a form with different fields of data to input. One of these fields has certain values it can be (I put a drop box here), but there can be no duplicate value in that table at the same time. Basically what I want to do is check for a duplicate record in the database through the server scripting. If there is no duplicate record, I want to insert the new data in the database. If there is a duplicate record, I want to make the user go back and pick a value for that field (which I called spot) that isn't already taken. Sorry about any confusion.
Reply With Quote
  #4 (permalink)  
Old 07-01-03, 11:29
JonathanB JonathanB is offline
Registered User
 
Join Date: Feb 2002
Location: North Wales, UK
Posts: 114
Grab all the used values from the table and store them in an array. When the user submits the form your code should loop through the array values checking if the value selected by the user has already been used before.

If it finds a match then it knows to redirect the user back to the form and inform them that the option they selected has already been used.
__________________
J^ - web | email
newsASP Developer
Reply With Quote
  #5 (permalink)  
Old 07-09-03, 19:06
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
Or you could do a select statement:

Code:
sSQL = "SELECT COUNT(ID) AS TotalIDs FROM myTable WHERE spot = '" & Trim(Request.Form("spot")) & "'"

'Execute code into recordset "objRS"

If objRS("TotalIDs") > 0 Then
    'Do error code saying the spot is taken
Else
    'Do an INSERT statement to take that spot
End If
"ID" is the column name you want to count (usually a unique ID column). "myTable" is the table that contains your rows of spots. "spot" is the column you're comparing with the input from the form. "objRS" is a recordset that gets populated with the total from the SELECT statement.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On