Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Asp Form.Request server error when values are blank

Status
Not open for further replies.

RussellDonders

Programmer
Jun 10, 2001
27
0
0
GB
Hi,

I tried searching for an answer to this but couldnt find a suitable solution.

I have 2 pages, one with a form to collect details about a person and a second that reads in this data and does stuff with it.

When all the values are entered on the form and submitted all works fine so I know I have everything set up right in that regard.

The problem occurs when the user leaves out an optional field .. such as company name. WHen this occurs I get an Internal Server Error when the 2nd asp page starts processing.

I am retrieving the values with lines such as :
set vcompany = Request.Form("company")

Is there another way I can do this to instead of having the script die if there is nothing in the company variable sent from my first form that it just enters into the vcompany variable an empty entry ?

I tried doing some error checking first to trick it into it :
if isNull(Request.Form("company")) then
vcompany = "";
else
set vcompany = Request.Form("company")
end if

but that didnt work.

Any help would be appreciated.

Thanks,

Russell
 
I think what u r explaining is not the cause of the problem. There i nothing wrong in leaving the companies name blank. The problem is somewhere else.... send the code of page 2 then we may get u the solution...
 
Hi,

Thanks for that.

well i do have more code .. the only bit that references these variables is when i write them to the database with the below code - could this be what is causing the error ? if it's trying to write a null value ?

Thanksm

Russell


<%
set conn = server.createobject(&quot;ADODB.Connection&quot;)

conn.open &quot;worldlanguage&quot;

SQL = &quot;INSERT INTO Customers (Username, Password, Name, Email, Company, Address1, Address2, Suburb, State, Postcode, Country, Phone, Fax) VALUES ( '&quot; & vusername & &quot;' ,'&quot; & vpassword & &quot;' ,'&quot; & vname & &quot;' ,'&quot; & vemail & &quot;' ,'&quot; & vcompany & &quot;' ,'&quot; & vaddress1 & &quot;' ,'&quot; & vaddress2 & &quot;' ,'&quot; & vsuburb & &quot;' ,'&quot; & vstate & &quot;' ,'&quot; & vpostcode & &quot;' ,'&quot; & vcountry & &quot;' ,'&quot; & vphone & &quot;' ,'&quot; & vfax & &quot;')&quot;

conn.execute(SQL)

conn.close
%>
 
I think the problem is in the line:

set vcompany = Request.Form(&quot;company&quot;)

Doesn't Request.Form(&quot;company&quot;) return the value in the company field? How about trying:

vcompany = Request.Form(&quot;company&quot;)

That way the vcompany variable should contain whatever is in the company or field (or nothing if nothing is in the field.) Ladyhawk. [idea]
** ASP/VB/Java Programmer **
 
yes u got it ... set will be used for objects only and not for strings ...
 
Hi LadyHawk,

I'm not too sure what Set does .. but i did before and I tried it again now - to get rid of the set like you suggested and it still came with the exact same error.

so my problem remains.

Thanks,

Russell
 
What is company, is it just a text box?

If you want, you can e-mail me (dagwood@powerup.com.au) the offending asp pages and I will have a little look for you.


Ladyhawk. [idea]
** ASP/VB/Java Programmer **
 
Does the companyfield in the database allow for NULL-values?! This is not a bug - it's an undocumented feature...
;-)
 
hey it is getting complicated now. Send the code for both the pages.
 
Try this

if Request.form(&quot;company&quot;) <> &quot;&quot; then
vcompany = request.form(&quot;company&quot;)
else
vcompany = &quot;null&quot;
end if

Sometimes the isNull function can cause some of the problems. This will actually put a value into the field to use in the insert statement, but the server shoudl interpret it as a null. You might need to work the syntax of the null field to get it to insert null value into the field.


 
If the Db field for Company is set to REQUIRE a value and that value is blank from the form, you will get an error...ensure the Db is allowing NULL, values in the field... Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Erhm... This is not a bug - it's an undocumented feature...
;-)
 
Thank You all very much .. you were extremely hot in giving me the correct answer and made me look where I should have to find it.

My access database did not have the values set to &quot;Required&quot; but DID have the &quot;Allow zero length fields&quot; to NO, I changed this and it looks like it's working ..

thanks again
Russell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top