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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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")) & "')"

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users


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.


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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

688 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