havey
08-22-2005, 07:35 PM
Hi , there is a table that has 20 columns, each column caould contain a promotion code. I have a form that a user fills out that contains a promo code field. When the user submit the form i'm comparing the promo field from the form to the values in the promo columns in the database and if a match then i'm setting the match value in the databse to nothing so the promo code cannot be used again.
My problem is trying to compare the form field value to the 20 column values in an efficient way.... below is my thinking which i think will turn out to be very inefficient:
If reference_code <> "" Then 'reference_code is the form field request value
Set c3B = server.createobject("ADODB.connection")
c3B.Open "Provider=sqloledb;" & _ ...........
.......
sq6 = "SELECT promo1, promo2, promo3, promo4, promo5, promo6, promo7, promo8, promo9, promo10, promo11, promo12, promo13, promo14, promo15, promo16, promo17, promo18, promo19, promo20, status FROM promo WHERE status = 'request_pending'"
Set r68 = c3B.Execute(sq6)
If r68.EOF Then
' do nothing so no error is displayed
End If
If reference_code = r68("promo1") Then
sq7 = "UPDATE promo SET promo1 = ' ' WHERE promo1 = '"&r68("promo1")&"'"
Set r69 = c3B.Execute(sq7)
response.redirect "promo.asp?type=true"
End If
If reference_code = r68("promo2") Then
sq7 = "UPDATE promo SET promo2 = ' ' WHERE promo2 = '"&r68("promo2")&"'"
Set r69 = c3B.Execute(sq7)
response.redirect "promo.asp?type=true"
End If
... and so on until r68("promo20")
// THANKS
My problem is trying to compare the form field value to the 20 column values in an efficient way.... below is my thinking which i think will turn out to be very inefficient:
If reference_code <> "" Then 'reference_code is the form field request value
Set c3B = server.createobject("ADODB.connection")
c3B.Open "Provider=sqloledb;" & _ ...........
.......
sq6 = "SELECT promo1, promo2, promo3, promo4, promo5, promo6, promo7, promo8, promo9, promo10, promo11, promo12, promo13, promo14, promo15, promo16, promo17, promo18, promo19, promo20, status FROM promo WHERE status = 'request_pending'"
Set r68 = c3B.Execute(sq6)
If r68.EOF Then
' do nothing so no error is displayed
End If
If reference_code = r68("promo1") Then
sq7 = "UPDATE promo SET promo1 = ' ' WHERE promo1 = '"&r68("promo1")&"'"
Set r69 = c3B.Execute(sq7)
response.redirect "promo.asp?type=true"
End If
If reference_code = r68("promo2") Then
sq7 = "UPDATE promo SET promo2 = ' ' WHERE promo2 = '"&r68("promo2")&"'"
Set r69 = c3B.Execute(sq7)
response.redirect "promo.asp?type=true"
End If
... and so on until r68("promo20")
// THANKS