ASP AND SQL SERVER (Problem in inserting a record)

When users register themselves on my website, i encountered a weird problem, when they finished filling up the forms and insert a new record, the record of fields on the last asp page(e.g. combo box, textbox) is "1000, 1000" when the value should be only "1000". That mean it append the result again, why is this so? On these last asp page before i execute the insert sql, there are some hidden fields where the value is passed from the previous asp page these hidden fields do not have value error while those visible field have value appended. Below are the brief section of my coding.

<input type=text name="Expected_Pay" align="right" size="8" maxlength="8" style="background-color:#ffffff">Per Month
<input type="hidden" name="EmailAddress" value="<%= Request.Form("EmailAddress")%>">
<input type="hidden" name="Password" value="<%= Request.Form("Password")%>">

Option Explicit
Response.Buffer = "true"

Dim objUpload
Set objUpload = server.createobject("ASPUpLoad.clsUpload")

Function StrQuoteReplace(strValue)
  If strValue <> "" And Not IsNull(StrValue) Then
  StrQuoteReplace = Replace(strValue, "'", "''")
  End If
End Function

addSQL = "INSERT INTO WebCandidate(EmailAddress, Password, Expected_Pay)" & "VALUES( '" & StrQuoteReplace(objUpload.Form("EmailAddress")) &  "', '" &  StrQuoteReplace(objUpload.Form("Password")) & "', '"  & StrQuoteReplace(objUpload.Form("Expected_Pay")) & "')"

NOTE!!!: I notice that only a small pool of users' record(maybe 1 out of 100) got this problem that rest of the records inserted are fine. It should not be programming error else i believe all the records should also have values appended. The weird thing is that only visible field has value appended and not those hidden fields... Pls help, thank in advance
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David H.H.LeeCommented:
>>...The weird thing is that only visible field has value appended and not those hidden fields...
-you can try this, maybe help to solve your problems :
Instead of
<input type="hidden" name="EmailAddress" value="<%= Request.Form("EmailAddress")%>">
<input type="hidden" name="Password" value="<%= Request.Form("Password")%>">

Change to
<input type="text" name="EmailAddress" style="visibility:hidden" value="<%= Request("EmailAddress")%>">
<input type="text" name="Password" style="visibility:hidden" value="<%= Request("Password")%>">

Owen10Author Commented:
The problem does not lies in the hidden fields as the values in those hidden fields are inserted correctly. those values that user key-in in the last page(fields that are visible) before the whole information process that come out with double value(e.g. 100, 100)

Try changing your sql statement to the below:

addSQL = "INSERT INTO WebCandidate(EmailAddress, Password, Expected_Pay)" & "VALUES( '" & StrQuoteReplace(objUpload.Form("EmailAddress")) &  "', '" &  StrQuoteReplace(objUpload.Form("Password")) & "', '"  & StrQuoteReplace(Request.Form("Expected_Pay")) & "')"

CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

I would say that this would cause you another issue.

Having used the clsUpload object before... it won't allow you to use Request.Form, Request.QueryString, or TRIM(request("")) with it's object. If you take a step back for a minute and just separate these out...

I did notice a syntax error in that last querystring ... so have amended below. Try this and let me know how you get on with this.

addSQL = "INSERT INTO WebCandidate(EmailAddress, Password, Expected_Pay)" &_
addSQL = addSQL & "VALUES( '" & StrQuoteReplace(objUpload.Form("EmailAddress")) &  "', '" &  StrQuoteReplace(objUpload.Form("Password")) & "', '"  & StrQuoteReplace(Request.Form("Expected_Pay")) & "')"


Another thing it might be of course, is that somehow there is two instances of the same field within the form.

<input type="hidden" name="fieldname" value="theValue">
<input type="hidden" name="fieldname" value="theValue">

If thats the case and two fields are the same, then it will append one to the other as it passes through the querystring. so you'll end up with ("1000,1000") All the same one worth checking out.

Owen10Author Commented:
DMD: Wat is the diffenence between ur Sql and my Sql?

butcherd11:My Sql shouldn't have any error because most of the user could add probably as i have mentioned. and y is the "expected_pay" the only field using request.form which i believe won't work with clsUpload? I got no duplicate value in different field. as i say again. most of the recorded added are correct except for a few of the users(1 out of 100) which has this problem.

With Regards,

Apologies.... yesterday was a bad day for me.. i kinda of missed the issue a little bit.

You are of course right, the syntax is correct, after looking again ... i do know though as specified above, the request.form shouldn't work anyway with the objUpload.Form, as it has conflicts with the different methods of request being used at the same time. ( so the top statement is correct. )

Is it only the expected pay field that it does this for ?

I've done a test by printing out aswell as inserting to the database as a test, and looping through to simulate your 100 times... and can't replicate this.
Owen10Author Commented:

Every1 has his day, bro...i having quite a few bad ones recently...

The scenario is this...there are a few registration pages(ASP), so from one page to another i would use request.form to pass in the value to a hidden field..
<input type="hidden" name="EmailAddress" value="<%= Request.Form("EmailAddress")%>">
<input type="hidden" name="Password" value="<%= Request.Form("Password")%>">
So on the last page of the registration, i already have quite a few hidden fields...there is still quite a few fields still to be complete on the last page. If the duplication occurs, it occurs to all the fields of the last page, be it combo or text and NOT those hidden fields that is also on the last page. Weird rite bro! how come hidden fields are not affected, maybe the values are pass-in using request.form to the hidden fields.

this error occur on 2 websites that i have because the styles are the same. The error occurs sort of ramdomise...i was thinking if it could be the users' coms that generate the error. Any idea?. BTW issit illegal to post our email here? so i can actually send u the coding that i have...

With Regards,
Just in case i'l split the email address up...

it's "butcherd" ...   Having tried something different to what i had originally tried, the only way i could force an appended query "100,100" was to have the form field called the same thing twice. second part of addy ""

Speak later dude.

Dave ;)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Owen10Author Commented:
Tat's for the effort thou the problem is still not solved...thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.