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.
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.
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.
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
'Do an INSERT statement to take that spot
"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.