ASP AND SQL SERVER (Problem in inserting a record)

Posted on 2003-11-10
Last Modified: 2008-03-06
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
Question by:Owen10
LVL 29

Expert Comment

by:David H.H.Lee
ID: 9720349
>>...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")%>">


Author Comment

ID: 9720927
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)

LVL 10

Expert Comment

ID: 9721722
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")) & "')"


Expert Comment

ID: 9722265
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.

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.


Author Comment

ID: 9729649
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,

Expert Comment

ID: 9731575

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.

Author Comment

ID: 9732471

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,

Accepted Solution

butcherd11 earned 100 total points
ID: 9738097
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 ;)

Author Comment

ID: 9863229
Tat's for the effort thou the problem is still not solved...thanks

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

911 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now