Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Clear Field in DB


Message #1 by "Graham Abrey" <design@t...> on Wed, 20 Feb 2002 18:54:07
I have got this error and its refering to a Textbox which is blank. This 

form will be used numerous times so I need it to be able to blank/clear 

some fields if necessary. Is there a way of doing this without sending a 

zero length string?

Currently I have this set up:-



CurrencyTypeOther = Request.Form("CurrencyTypeOther")



rsItem("CurrencyTypeOther") = CurrencyTypeOther



 Gives me 



Error Type:

Microsoft JET Database Engine (0x80040E21)

Field 'Jobs.CurrencyTypeOther' cannot be a zero-length string.

/jobs/checkcreatejob3.asp, line 311



Thanks

Graham
Message #2 by "Ken Schaefer" <ken@a...> on Thu, 21 Feb 2002 12:32:04 +1100
Do you want to insert a NULL?



<%

CurrencyTypeOther = Request.Form("CurrencyTypeOther")

If Len(CurrencyTypeOther) = 0 then

    CurrentTypeOther = NULL

End If

%>



PS Always validate your incoming data:

www.adopenstatic.com/resources/code/UIValidation.asp



Cheers

Ken



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

From: "Graham Abrey" <design@t...>

Subject: [access_asp] Clear Field in DB





: I have got this error and its refering to a Textbox which is blank. This 

: form will be used numerous times so I need it to be able to blank/clear 

: some fields if necessary. Is there a way of doing this without sending a 

: zero length string?

: Currently I have this set up:-

: 

: CurrencyTypeOther = Request.Form("CurrencyTypeOther")

: 

: rsItem("CurrencyTypeOther") = CurrencyTypeOther

: 

:  Gives me 

: 

: Error Type:

: Microsoft JET Database Engine (0x80040E21)

: Field 'Jobs.CurrencyTypeOther' cannot be a zero-length string.

: /jobs/checkcreatejob3.asp, line 311

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Message #3 by "Zee Computer Consulting" <zee@t...> on Wed, 20 Feb 2002 18:23:27 -0800
Quick and dirty workaround, as long as an "all-blank" field is OK, is to add

a space to the end of the string to be saved:



     rsItem("CurrencyTypeOther") = CurrencyTypeOther & " "



Does this help?



-- Z









----- Original Message -----

From: "Graham Abrey" <design@t...>

To: "Access ASP" <access_asp@p...>

Sent: Wednesday, February 20, 2002 6:54 PM

Subject: [access_asp] Clear Field in DB





> I have got this error and its refering to a Textbox which is blank. This

> form will be used numerous times so I need it to be able to blank/clear

> some fields if necessary. Is there a way of doing this without sending a

> zero length string?

> Currently I have this set up:-

>

> CurrencyTypeOther = Request.Form("CurrencyTypeOther")

>

> rsItem("CurrencyTypeOther") = CurrencyTypeOther

>

>  Gives me

>

> Error Type:

> Microsoft JET Database Engine (0x80040E21)

> Field 'Jobs.CurrencyTypeOther' cannot be a zero-length string.

> /jobs/checkcreatejob3.asp, line 311

>

> Thanks

> Graham




$subst('Email.Unsub').

>



Message #4 by "Raymond Dalton" <rdalton@c...> on Fri, 22 Feb 2002 17:10:22
I take it you are using an access database.  Within Access select your 

table and go into the design view.  Then go to the field and look at the 

properties under the general tab.  There will be a property for the field 

called "Allow Zero Length".  This property defaults to No.  When you go to 

add a row to the table using ADO and you try to insert a zero length 

string you will get the error that you describe.  Change the value to Yes, 

and it should take care of your problem.



Thanks,



Raymond



> I have got this error and its refering to a Textbox which is blank. This 

> form will be used numerous times so I need it to be able to blank/clear 

> some fields if necessary. Is there a way of doing this without sending a 

> zero length string?

> Currently I have this set up:-

> 

> CurrencyTypeOther = Request.Form("CurrencyTypeOther")

> 

> rsItem("CurrencyTypeOther") = CurrencyTypeOther

> 

>  Gives me 

> 

> Error Type:

> Microsoft JET Database Engine (0x80040E21)

> Field 'Jobs.CurrencyTypeOther' cannot be a zero-length string.

> /jobs/checkcreatejob3.asp, line 311

> 

> Thanks

> Graham
Message #5 by "Graham Abrey" <design@t...> on Fri, 22 Feb 2002 22:41:48
Thanks all,

You have all been helpful. I have used the adding of a single blank space 

character before but later on I need to check if the length is zero. I 

have however reverted to using the NULL method. Its also useful knowing 

how to set access to accept zero length strings. 



Thanks all again

Graham





> I take it you are using an access database.  Within Access select your 

> table and go into the design view.  Then go to the field and look at 

the 

> properties under the general tab.  There will be a property for the 

field 

> called "Allow Zero Length".  This property defaults to No.  When you go 

to 

> add a row to the table using ADO and you try to insert a zero length 

> string you will get the error that you describe.  Change the value to 

Yes, 

> and it should take care of your problem.

> 

> Thanks,

> 

> Raymond

> 

> > I have got this error and its refering to a Textbox which is blank. 

This 

> > form will be used numerous times so I need it to be able to 

blank/clear 

> > some fields if necessary. Is there a way of doing this without 

sending a 

> > zero length string?

> > Currently I have this set up:-

> > 

> > CurrencyTypeOther = Request.Form("CurrencyTypeOther")

> > 

> > rsItem("CurrencyTypeOther") = CurrencyTypeOther

> > 

> >  Gives me 

> > 

> > Error Type:

> > Microsoft JET Database Engine (0x80040E21)

> > Field 'Jobs.CurrencyTypeOther' cannot be a zero-length string.

> > /jobs/checkcreatejob3.asp, line 311

> > 

> > Thanks

> > Graham

  Return to Index