ASP AND SQL SERVER (Problem in inserting a record)

Posted on 2003-11-10
Medium Priority
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")) & "')"

Basic Security of Your VPC

So, you’ve got this shiny new VPC and a fancy new application configured on your EC2 servers ready to go. This application is only accessible from your computer, which is great for security, but you need your users to be able to access it! So, what’s the easiest way to do this?


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 300 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 "@interleasing.co.uk"

Speak later dude.

Dave ;)

Author Comment

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

Featured Post

How To Install Bash on Windows 10

Windows’ budding partnership with Canonical has certainly led to some great improvements. One of them being the ability to use Bash on your Windows machine without third party applications! This might be one of the greatest things a cloud engineer in a Windows environment can do!

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

762 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